Preview:
n=int(input('enter number:'))
for i in range(2,n+1):
    for j in range(2,i//+1):
        if i%j==0:
            break
    else:
        print(i,end=' ')
        
        
(OR)


def prime(n):
    if n<2:
        return 0
    else:
        for i in range(2,n//2+1):
            if n%i==0:
                return 0
        return 1

n=int(input('enter number:'))
for i in range(1,n+1):
    if prime(i):
        print(i,end=' ')
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter