aboutsummaryrefslogtreecommitdiff
path: root/challenge-133/paulo-custodio/python/ch-1.py
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2021-11-01 15:35:34 +0800
committer冯昶 <seaker@qq.com>2021-11-01 15:35:34 +0800
commit47c592ce79003fa05dc7f2d5d1f22c5ef2ff1b4e (patch)
treee17cb3ca27261d8e37f610cd90a8081a2110e6ff /challenge-133/paulo-custodio/python/ch-1.py
parent6feeaa5f2efa5e3a0e27aa9610f0f686ea7c34a8 (diff)
parentaa267843f108e0b591cbbf2f13428354c74b2f70 (diff)
downloadperlweeklychallenge-club-47c592ce79003fa05dc7f2d5d1f22c5ef2ff1b4e.tar.gz
perlweeklychallenge-club-47c592ce79003fa05dc7f2d5d1f22c5ef2ff1b4e.tar.bz2
perlweeklychallenge-club-47c592ce79003fa05dc7f2d5d1f22c5ef2ff1b4e.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-133/paulo-custodio/python/ch-1.py')
-rw-r--r--challenge-133/paulo-custodio/python/ch-1.py84
1 files changed, 42 insertions, 42 deletions
diff --git a/challenge-133/paulo-custodio/python/ch-1.py b/challenge-133/paulo-custodio/python/ch-1.py
index 69d2f7e92b..1b905ee574 100644
--- a/challenge-133/paulo-custodio/python/ch-1.py
+++ b/challenge-133/paulo-custodio/python/ch-1.py
@@ -1,42 +1,42 @@
-#!/usr/bin/env python3
-
-# TASK #1 > Integer Square Root
-# Submitted by: Mohammad S Anwar
-# You are given a positive integer $N.
-#
-# Write a script to calculate the integer square root of the given number.
-#
-# Please avoid using built-in function. Find out more about it here.
-#
-# Examples
-# Input: $N = 10
-# Output: 3
-#
-# Input: $N = 27
-# Output: 5
-#
-# Input: $N = 85
-# Output: 9
-#
-# Input: $N = 101
-# Output: 10
-
-# solution: https://en.wikipedia.org/wiki/Integer_square_root
-
-import sys
-
-def isqrt(n):
- x0 = n >> 1 # initial estimate
- if x0 == 0:
- return n
-
- # loop
- x1 = int(x0 + n/x0) >> 1
- while x1 < x0:
- x0 = x1;
- x1 = int(x0 + n/x0) >> 1
-
- return x0
-
-n = int(sys.argv[1])
-print(isqrt(n))
+#!/usr/bin/env python3
+
+# TASK #1 > Integer Square Root
+# Submitted by: Mohammad S Anwar
+# You are given a positive integer $N.
+#
+# Write a script to calculate the integer square root of the given number.
+#
+# Please avoid using built-in function. Find out more about it here.
+#
+# Examples
+# Input: $N = 10
+# Output: 3
+#
+# Input: $N = 27
+# Output: 5
+#
+# Input: $N = 85
+# Output: 9
+#
+# Input: $N = 101
+# Output: 10
+
+# solution: https://en.wikipedia.org/wiki/Integer_square_root
+
+import sys
+
+def isqrt(n):
+ x0 = n >> 1 # initial estimate
+ if x0 == 0:
+ return n
+
+ # loop
+ x1 = int(x0 + n/x0) >> 1
+ while x1 < x0:
+ x0 = x1;
+ x1 = int(x0 + n/x0) >> 1
+
+ return x0
+
+n = int(sys.argv[1])
+print(isqrt(n))