Numbers k such that the last letter of k is the same as the first letter of k+1: Difference between revisions
Content added Content deleted
(Python example) |
m (→{{header|Python}}: cleanuup unneeded) |
||
Line 330: | Line 330: | ||
except for numbers > 1000 which are divisible by 1000 """ |
except for numbers > 1000 which are divisible by 1000 """ |
||
groups = [] |
groups = [] |
||
if n < 1: # exception for zero, return array containing zero |
|||
return [n] |
|||
while n > 0: |
while n > 0: |
||
n, r = divmod(n, 1000) |
n, r = divmod(n, 1000) |
||
Line 344: | Line 342: | ||
def lastletter(n): |
def lastletter(n): |
||
return num2words(n)[-1] if |
return num2words(n)[-1] if n % 1000 == 0 else spelledcache[nonzerogroupings(n)[0]][-1] |
||
else spelledcache[nonzerogroupings(n)[0]][-1] |
|||
def qualifies(n): |
def qualifies(n): |