Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from fractions import Fraction
def get_fractions(m=5):
all_fractions = [Fraction(nume,deno) for deno in range(1,m+1) for nume in range(0,deno+1)]
uniq_fractions = set(all_fractions)
fractions_list = list(uniq_fractions)
return fractions_list
for i in range(10):
from collections import Counter
import math
single_prime_digits = [2,3,5,7]
def factors(n):
while n > 1:
for i in single_prime_digits:
if n % i == 0:
n /= i
yield i
def get_all_factors(x):
return [m for m in factors(x)]
# for i in [360,100,1000,1,10]:
# print(get_all_factors(i))
def get_numdigits(x):
if x in [0,1]:
return 1
all_factors = get_all_factors(x)
mul_num = 1
for i in all_factors:
if mul_num!=x:
return -1
counts = Counter(get_all_factors(x))
count_2 = math.ceil(counts[2]/3)
count_3 = math.ceil(counts[3]/2)
digit_count = counts[5]+counts[7]+count_2+count_3
return digit_count
for i in [32,10**10+2]:
print(i, get_numdigits(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.