# Problems on these two questions

Dave Angel d at davea.name
Mon Nov 19 03:18:19 CET 2012

```On 11/18/2012 08:52 PM, su29090 wrote:
> I all of the other problems but I have issues with these:
>
> 1.Given a positive integer  n , assign True to  is_prime if  n has no factors other than  1 and itself. (Remember,  m is a factor of  n if  m divides  n evenly.)

if is_a_prime(n):
is_prime = True

Now all you have to do is write is_a_prime().  if you get stuck, please
show us what you've got, and what the problem is with it.  And as usual,
tell us what version of Python you're writing in, if any.

> 2.An  arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if the same. This in the sequence  1, 3, 5, 7, ... , the distance is 2 while in the sequence  6, 12, 18, 24, ... , the distance is 6.
>
>  Given the positive integer  distance and the positive integer  n , associate the variable  sum with the sum of the elements of the arithmetic progression from  1 to  n with distance  distance . For example, if  distance is 2 and  n is  10 , then  sum would be associated with  26 because  1+3+5+7+9 = 25 .

Don't call it 'sum' since that's a built-in function.  Coincidentally,
it's a function that takes an iterable, and calculates the sum of its
elements.  Sounds useful, no?  The other thing you might want is xrange,
which takes a start value, and end value, and a distance value.

>

You never responded to any of the messages in the other thread.  But
Chris's advice was good, and better worded than mine.  Pick a problem,
make an attempt, then ask for help.

--

DaveA

```