import math def digits(num): digits = 0 while num >= 1: digits +=1 num = num/10 return digits def panDigital(num): tempNum = num dgts = digits(num) #check for illegal digits - 0, too high while tempNum >= 1: if tempNum % 10 == 0: return False elif tempNum % 10 > dgts: return False tempNum = tempNum / 10 checker = [0]*dgts tempNum = num while tempNum >= 1: if checker[tempNum%10-1] == 1: #already taken return False else: checker[tempNum%10-1] = 1 tempNum = tempNum/10 return True def primeList(maxnum): lst = [] lst.append(2) prm = 3 print "Checking ", prm while prm < maxnum: print "got here" index = 0 while index < len(lst): if prm % lst[index] == 0: #not prime print "break" break index = index + 1 print prm + " mod " + lst[index] if index == len(lst): lst.append(prm) prm = prm + 2 return lst primeList(5)
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