Numbers k such that the last letter of k is the same as the first letter of k+1: Difference between revisions

→‎{{header|J}}: bugfix (*last* letter of k, not first letter of k)
(J draft)
(→‎{{header|J}}: bugfix (*last* letter of k, not first letter of k))
Line 38:
Using [[Number names#J|Number names]], we can generate a sample of the desired numbers which (in this example) are smaller than a million:
 
<syntaxhighlight lang=J> #sample=: I.({.:=1|.!.' '{:.)|:({.,{:)@us"0 i.1e6
91401
91403
5 10$sample NB. first fifty
10 18 8 28 938 1179 2781 3783 8085 8297 84 88102
96122 101132 121142 131152 141162 151172 161182 171192 181208 191228
207238 227248 237258 247268 257278 267288 277298 287308 297328 307338
327348 337358 347368 357378 367388 377398 387799 397801 800803 802805
804809 808812 811821 820823 822825 824829 828831 830833 832835 834839
(],. sample {~ <:) 1e3 1e4 NB. 1000th and 10000th
1000 1096710988
10000 106631106652
(~.,.#/.~) /:~10|1e3{.sample NB. counts by final digit
0 111 12
1 112111
2 111110
3 11111
4 111 11
5 11111
6 111 11
7 298111
8 112301
9 12111
(~.,.#/.~) /:~10|1e4{.sample NB. counts by final digit
0 1301 122
1 8291301
2 1301 829
3 1211301
4 1301 121
5 1211301
6 1211 121
7 23911211
8 13022392
9 1221301</syntaxhighlight>
 
=={{header|Wren}}==
6,962

edits