aboutsummaryrefslogtreecommitdiff
path: root/challenge-085/lubos-kolouch/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-085/lubos-kolouch/python/ch-2.py')
-rw-r--r--challenge-085/lubos-kolouch/python/ch-2.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-085/lubos-kolouch/python/ch-2.py b/challenge-085/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..1f93585797
--- /dev/null
+++ b/challenge-085/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,25 @@
+#!/bin/env python
+" Task 2 Challenge 085 "
+
+from math import log, sqrt
+
+
+def is_power_two_integers(what):
+ " Find out if the number can be represented as x^y "
+
+ if what == 1:
+ return 1
+
+ for i in range(2, int(sqrt(what)) + 1):
+ diff = log(what) / log(i)
+
+ if diff - int(diff) < 0.00000001:
+ return 1
+
+ return 0
+
+
+assert is_power_two_integers(8) == 1
+assert is_power_two_integers(15) == 0
+assert is_power_two_integers(125) == 1
+assert is_power_two_integers(625) == 1