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
def newton(n, r, p = 0): | |
""" | |
(int(n), num(r), int(p)) -> float | |
Return the nth root of a positive number r displaying p correct decimals. | |
""" | |
x = 1 # start with guess = 1 | |
while True: | |
fx = x**n - r # function of this form solves all roots |
NewerOlder