Skip to content

Instantly share code, notes, and snippets.

@sedaghatfar
Created May 16, 2013 19:58
Show Gist options
  • Save sedaghatfar/5594606 to your computer and use it in GitHub Desktop.
Save sedaghatfar/5594606 to your computer and use it in GitHub Desktop.
x = int(input("enter an integer: "))
ans = 0
while ans*ans*ans < abs(x):
ans = ans +1
print ("current Guess =", ans)
print ("last guess = ", ans)
print ("ans*ans*ans = ", ans*ans*ans)
if ans*ans*ans == abs(x):
if x<0:
ans = -ans
print ("cube root of " + str(x) + " is " + str(ans))
else:
print (x, "is not a perfect cube")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment