[Tutor] Creatively solving math problems -----help
TJ
tgrimes at teleport.com
Tue Sep 9 18:46:40 EDT 2003
Try using the modulo operator %. It returns the remainder of a division.
Examples:
>>> 301 % 2
1
>>> 301 % 3
1
>>> 301 % 4
1
>>> 301 % 5
1
>>> 301 % 6
1
>>> 301 % 7
0
TJ
>hey i was trying to solve a math problem creativily and i wrote this
>script. Can anyone tell me why it doesn't work and how to fix it.
>
>
>for x in range(20000):
> if x/2 == int(x/2) and x/3 == int(x/3) and x/4 == int(x/4) and \
> x/5 == int(x/5) and x/6 == int(x/6) and x/7-1 == int(x/7-1):
>
> print x
>
>
> else:
> pass
>
>
>The question is what whole numbers can be divided by 2-6 and have a
>remainder of 1 but divided by 7 and have no remainder. I already have
>the answer;
>301 and then you add 420 each time.
More information about the Tutor
mailing list