Numbers k such that the last letter of k is the same as the first letter of k+1: Difference between revisions
Numbers k such that the last letter of k is the same as the first letter of k+1 (view source)
Revision as of 20:47, 1 July 2023
, 10 months ago→{{header|Python}}
m (→{{header|Julia}}: simplify) |
|||
Line 550:
firstcache, lastcache = [s[0] for s in spelledcache], [s[-1] for s in spelledcache]
def
if n == 0:▼
'n' if n % 1_000_000 == 0
j = 0
while n > 0:
n, j = divmod(n, 1000)
return firstcache[j] == lastchar
▲ return lastcache[n % 1000] if n % 1000 > 0 else 'o' if n == 0 else \
def testqualifies():
|