import math def calc(x, goal): i=0 while(x<goal): print(x) x*=x i+=1 if(x==goal): print("Goal Reached! X = " + str(x)) elif(x>goal): print("Goal Overshot " + "After " + str(i) + " Tries! X = " + str(x) + "") print("Sqrt of sqrt of X overshot is: " + str(int(math.sqrt(math.sqrt(x))))) print("Will try with that to the power of three...") print("Got: " + str(int((math.sqrt(math.sqrt(x)))**3))) if(int((math.sqrt(math.sqrt(x)))**3)==goal): print("Made it with sqrt of sqrt of x overshot to the power of three!") elif(int((math.sqrt(math.sqrt(x)))**3)<goal): print("Still didn't work, trying to the power of four...") print("Got: " + str(int(math.sqrt(math.sqrt(x))**4))) print(3**28) calc(3, 3**28)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question