Skip to content

Instantly share code, notes, and snippets.

@junichiro
Created January 28, 2015 02:53
Show Gist options
  • Save junichiro/d8fb05ad01dbc103bc31 to your computer and use it in GitHub Desktop.
Save junichiro/d8fb05ad01dbc103bc31 to your computer and use it in GitHub Desktop.
code_iq: 1241
# -*- coding: utf-8 -*-
class code_iq:
def get_kai_insu_cnt(self, n):
if n > 2:
i2, io = 0, 0
a = self.get_insu_cnt(n)
b = self.get_kai_insu_cnt(n - 1)
return (a[0] + b[0], a[1] + b[1])
else:
return (1, 0)
def get_insu_cnt(self, n):
prime_numbers = self.prime_numbers()
i2, io = 0, 0
while len(prime_numbers) > 0:
a = prime_numbers.pop()
while True:
if n % a == 0:
n = n / a
if a == 2:
i2 = i2 + 1
else:
io = io + 1
else:
break
return (i2, io)
def prime_numbers(self):
return [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293]
if __name__ == '__main__':
code = code_iq()
result = []
for v in range(2, 305 + 1):
res = code.get_kai_insu_cnt(v)
if res[0] == res[1]:
print v, res
result.append((v, res))
print len(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment