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
m (→{{header|Julia}}: simplify) |
|||
Line 325: | Line 325: | ||
firstcache, lastcache = map(first, spelledcache), map(last, spelledcache) |
firstcache, lastcache = map(first, spelledcache), map(last, spelledcache) |
||
function |
function inOEIS363659(n) |
||
⚫ | |||
n == 0 && return 'z' |
|||
n += 1 |
|||
j = 0 |
j = 0 |
||
while n > 0 |
while n > 0 |
||
n, j = divrem(n, 1000) |
n, j = divrem(n, 1000) |
||
end |
end |
||
return firstcache[j] |
return firstcache[j] == lastchar |
||
end |
end |
||
function lastletter(n) |
|||
⚫ | |||
lastcache[n % 1000] |
|||
end |
|||
inOEIS363659(n) = lastletter(n) == firstletter(n + 1) |
|||
""" test the sequence """ |
""" test the sequence """ |