Least Prime Factor in Python

Program of Least Prime Factor in Python


t=int(input())
for i in range(t):
    n=int(input())
    for j in range(1,n+1):
        flag=0
        for k in range(2,j+1):
            if(j%k==0):
                print(k,end=" ")
                flag=1
                break
        if(flag==0):
            print(j,end=" ")
    print()

Comments