Created
May 16, 2013 19:58
-
-
Save sedaghatfar/5594606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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