def primes(n): s=range(0,n+1) s[1]=0 bottom=2 top=n//bottom while (bottom*bottom<=n): while (bottom<=top): if s[top]: s[top*bottom]=0 top-=1 bottom+=1 top=n//bottom print [x for x in s if x], ", ", def digital_root(nn): r = 0 for n in str(nn): r += int(n) return r def get_digital_root(bn): while (bn > 9): bn = int(digital_root(bn)) return bn pr = primes(100000) c = 0 #print #for p in pr: # c+=1 # dd = (get_digital_root(p)), # print dd[0], # if c % 100 == 0: # print # # print " - ", p
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