[Tutor] Creatively solving math problems -----help
Conrad Koziol
arkamir at softhome.net
Wed Sep 10 00:48:02 EDT 2003
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. The problem is the program gives me
every number between 1 and 19999. Also i was wondering how many line
breaks can you use? I believe it gives me 1-19999 because im using ==
but if i use only 1 = it gives me a syntax error. I believe this has
something to do with the int(). Also int() returns it rounded down, is
there any subsitute so it rounds to the nearest whole number.
Another way i though i could solve this was by a script that looks like
this:
for x in range(2000):
if x/2 = int(x/2):
continue
else:
??????????
the script would continue like this all the way to 7. The problem is i
dont know a command that if if proves true skips that iteration and goes
on to the next one.Any help??
thanks
More information about the Tutor
mailing list