Skip to content

Commit baa714d

Browse files
Square Root implemented in Python
1 parent be90705 commit baa714d

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed
File renamed without changes.
File renamed without changes.

Math/squareroot/Python/square_root.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def sqroot(x):
2+
if x == 0:
3+
return 0
4+
5+
counter = 1
6+
while pow(counter, 2) <= x:
7+
counter += 1
8+
counter -= 1
9+
10+
return counter
11+
12+
13+
num = int(raw_input())
14+
sqrt_num = sqroot(num)
15+
16+
print "The square root of the number %d is %d" % (num, sqrt_num)

0 commit comments

Comments
 (0)