Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6e0467c

Browse files
Seems to be doing what it should? Need to implement auto loop stopping
1 parent e3fc6f4 commit 6e0467c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎9-NewtonSquareRoots.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
x = float(input("Enter a number: "))
1313
z = float(input("Sqrt guess: "))
1414

15-
print("Math.sqrt(x): " + str(math.sqrt(x))) # Accurate sqrt
15+
print("Math.sqrt(x): \t" + str(math.sqrt(x))) # Accurate sqrt
1616

1717
approximate = z - ((z*z - x) / (2 * z))
18-
print("Approximate: " + str(approximate))
18+
19+
for i in range (0,3):
20+
z = approximate
21+
approximate = z - ((z*z - x) / (2 * z))
22+
23+
print("Approximate: \t" + str(approximate))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /