Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Casting-out-nines/Python/casting-out-nines.py
Normal file
19
Task/Casting-out-nines/Python/casting-out-nines.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Casting out Nines
|
||||
#
|
||||
# Nigel Galloway: June 27th., 2012,
|
||||
#
|
||||
def CastOut(Base=10, Start=1, End=999999):
|
||||
ran = [y for y in range(Base-1) if y%(Base-1) == (y*y)%(Base-1)]
|
||||
x,y = divmod(Start, Base-1)
|
||||
while True:
|
||||
for n in ran:
|
||||
k = (Base-1)*x + n
|
||||
if k < Start:
|
||||
continue
|
||||
if k > End:
|
||||
return
|
||||
yield k
|
||||
x += 1
|
||||
|
||||
for V in CastOut(Base=16,Start=1,End=255):
|
||||
print(V, end=' ')
|
||||
Loading…
Add table
Add a link
Reference in a new issue