/ Published in: Python
Try it out in a python interpreter!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def mathprob_no_print(x): string2 = str(x) while x != 1: if x % 2 == 0: x = x/2 else: x = 3 * x + 1 if x == 1: return string2+" was a failure" else: return string2+" passed the test!" def math_repeat(x,p): while x <= p: print mathprob_no_print(x) x = x + 1 math_repeat(1,100)