"""Enter a positive integer to recieve a list of prime numbers within the range of 0 to your entered number. """ from math import sqrt prime_list = [] number = int(raw_input()) for n in range(2, number + 1): save_time = int(sqrt(n)) for x in prime_list: if n % x == 0: break if x >= save_time: print n prime_list.append(n) break else: print n prime_list.append(n)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question