We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bff6256 commit c5f4047Copy full SHA for c5f4047
find_square_root.py
@@ -0,0 +1,18 @@
1
+
2
+# This method is called exhaustive numeration!
3
+# I am checking every possible value
4
+# that can be root of given x systematically
5
+# Kinda brute forcing
6
7
+def find_square_root(x):
8
+ if type(x) == str:
9
+ return "Expected an integer! Cannot find square root of an string!"
10
+ for i in range(x):
11
+ if i ** 2 == x:
12
+ return i
13
+ return "{} is not a perfect square".format(x)
14
15
+# Test
16
+x = 2
17
+result = find_square_root(x)
18
+print("Square root of {} is {}".format(x, result))
0 commit comments