Untitled

 avatar
unknown
python
2 years ago
848 B
6
Indexable
from math import sqrt
from collections import Counter
def prime_no(a):
    for i in range(2,a-1):
        if a%i ==0:
            return False
    return True

def firstfact(a):
     factor=0
     for i in range(2,(int(sqrt(a))+1)):
        if prime_no(i):
            if a%i==0:
                factor=i
                return factor
                break

def factorise(a):
    fact=[]
    while True:
        fact.append(firstfact(a))
        treeno=int(a/firstfact(a))
        if prime_no(treeno):
            fact.append(treeno)
            return(fact)
            break
        a=treeno
    
powers=[None]*19

for i in range(19):
    print("index+2",i+2)
    if prime_no(i+2):
        powers[i]=1
    else:
        print("non-prime",i+2)
        factored=factorise(i+2)
        print(Counter(factored))
Editor is loading...
Leave a Comment