Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- 4. Make a set of first X primary numbers (X entered from keyboard).
- Print out the set.
- 4.1. Transform set into ordered sequence of numbers and print out again.
- """
- counter=int(input("enter number"))
- primes=set()
- first = 1
- last = 1000000 #not elegant..... I tried while counter > 0 and then decrease the counter every time I find prime, but did not work well... ever....
- for val in range(first, last + 1):
- if val > 1:
- for n in range(2, val):
- if (val % n) == 0:
- break
- else:
- primes.add(val)
- if len(primes)==counter:
- break
- else:
- first=last
- last=first+1
- print(primes)
- primes2=list(primes)
- primes2.sort()
- print(primes2)
Add Comment
Please, Sign In to add comment