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
Line 71: Line 71:
8 2392
8 2392
9 1301</syntaxhighlight>
9 1301</syntaxhighlight>

=={{header|Julia}}==
<syntaxhighlight lang="julia">using Formatting, SpelledOut, UnicodePlots

spell(n) = spelled_out(n, lang = :en)

qualifies(n) = spell(n)[end] == spell(n + 1)[begin]

function testqualifies()
ncount = 0
lastdigits = UInt8[]
println("First 50 numbers")
for n in 0:typemax(Int32)
if qualifies(n)
ncount += 1
push!(lastdigits, n % 10)
if ncount < 51
print(rpad(n, 5), ncount % 10 == 0 ? "\n" : "")
elseif ncount in [10^3, 10^4, 10^5, 10^6]
println("\nThe $(spell(ncount))th number is $(format(n, commas = true)).")
println("Breakdown by last digit of the qualifiers up to this:")
display(histogram(lastdigits))
println()
ncount == 1_000_000 && break
end
end
end
end

testqualifies()
</syntaxhighlight>{{out}}
<pre>
First 50 numbers
0 18 28 38 79 81 83 85 97 102
122 132 142 152 162 172 182 192 208 228
238 248 258 268 278 288 298 308 328 338
348 358 368 378 388 398 799 801 803 805
809 812 821 823 825 829 831 833 835 839

The one thousandth number is 10,988.
Breakdown by last digit of the qualifiers up to this:
┌ ┐
[ 0.0, 1.0) ┤█▍ 12
[ 1.0, 2.0) ┤████████████▊ 111
[ 2.0, 3.0) ┤████████████▊ 110
[ 3.0, 4.0) ┤████████████▊ 111
[ 4.0, 5.0) ┤█▍ 11
[ 5.0, 6.0) ┤████████████▊ 111
[ 6.0, 7.0) ┤█▍ 11
[ 7.0, 8.0) ┤████████████▊ 111
[ 8.0, 9.0) ┤███████████████████████████████████ 301
[ 9.0, 10.0) ┤████████████▊ 111
└ ┘
Frequency


The ten thousandth number is 106,652.
Breakdown by last digit of the qualifiers up to this:
┌ ┐
[ 0.0, 1.0) ┤█▋ 122
[ 1.0, 2.0) ┤█████████████████▉ 1 301
[ 2.0, 3.0) ┤███████████▌ 829
[ 3.0, 4.0) ┤█████████████████▉ 1 301
[ 4.0, 5.0) ┤█▋ 121
[ 5.0, 6.0) ┤█████████████████▉ 1 301
[ 6.0, 7.0) ┤█▋ 121
[ 7.0, 8.0) ┤████████████████▋ 1 211
[ 8.0, 9.0) ┤█████████████████████████████████ 2 392
[ 9.0, 10.0) ┤█████████████████▉ 1 301
└ ┘
Frequency


The one hundred thousandth number is 1,095,542.
Breakdown by last digit of the qualifiers up to this:
┌ ┐
[0.0, 0.5) ┤█▋ 1 122
[0.5, 1.0) ┤ 0
[1.0, 1.5) ┤████████████████▊ 11 301
[1.5, 2.0) ┤ 0
[2.0, 2.5) ┤████████████████████████████▎ 18 829
[2.5, 3.0) ┤ 0
[3.0, 3.5) ┤████████████████▊ 11 301
[3.5, 4.0) ┤ 0
[4.0, 4.5) ┤█▋ 1 121
[4.5, 5.0) ┤ 0
[5.0, 5.5) ┤████████████████▊ 11 301
[5.5, 6.0) ┤ 0
[6.0, 6.5) ┤█▋ 1 121
[6.5, 7.0) ┤ 0
[7.0, 7.5) ┤████████████████▊ 11 211
[7.5, 8.0) ┤ 0
[8.0, 8.5) ┤████████████████████████████████ 21 392
[8.5, 9.0) ┤ 0
[9.0, 9.5) ┤████████████████▊ 11 301
└ ┘
Frequency


The one millionth number is 10,984,428.
Breakdown by last digit of the qualifiers up to this:
┌ ┐
[0.0, 0.5) ┤█▎ 11 123
[0.5, 1.0) ┤ 0
[1.0, 1.5) ┤███████████▌ 111 301
[1.5, 2.0) ┤ 0
[2.0, 2.5) ┤███████████▍ 110 230
[2.5, 3.0) ┤ 0
[3.0, 3.5) ┤███████████▌ 111 301
[3.5, 4.0) ┤ 0
[4.0, 4.5) ┤█▎ 11 121
[4.5, 5.0) ┤ 0
[5.0, 5.5) ┤███████████▌ 111 301
[5.5, 6.0) ┤ 0
[6.0, 6.5) ┤█▎ 11 121
[6.5, 7.0) ┤ 0
[7.0, 7.5) ┤███████████▌ 111 211
[7.5, 8.0) ┤ 0
[8.0, 8.5) ┤███████████████████████████████ 299 990
[8.5, 9.0) ┤ 0
[9.0, 9.5) ┤███████████▌ 111 301
└ ┘
Frequency

</pre>



=={{header|Wren}}==
=={{header|Wren}}==