1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #!/usr/bin/ruby
- # Numbers k such that the decimal expansion of the k-th harmonic number starts with the digits of k, in the same order.
- # https://oeis.org/A337904
- # This program generates such values of `k` (with possible gaps?).
- func isok(k) {
- k.harmreal.to_s.sub('.', '').first(k.len) == k.to_s
- }
- var n = 1
- for k in (1..100) {
- local Num!PREC = numify(4*(n + 10))
- if (harmreal(k * 10**n).to_s.begins_with(k.to_s)) {
- var (min, max) = (harmreal(k * 10**n) * 10**n, harmreal((k+1) * 10**n) * 10**n)
- var v = bsearch_le(min, max, {|k|
- (k / 10**n) <=> harmreal(k)
- })
- var ok = false
- if (isok(v-1)) {
- say v-1
- ok = true
- }
- if (isok(v)) {
- say v
- ok = true
- }
- ++n if ok
- }
- }
- __END__
- 43
- 714
- 715
- 9763
- 122968
- 122969
- 1478366
- 17239955
- 196746419
- 2209316467
- 24499118645
- 268950072605
- 2928264676792
- 31663398162514
- 340383084842938
- 3640820101879826
- 38773735148047406
- 38773735148047407
- 411354473689969709
- 4349378018952283972
- 45849102972919835109
- 482017272880546223321
- 5055191842047792613562
- 52899904144628296988725
- 552458815055031196782525
- 5759002212954326201649741
- 59932476432458393252342721
- 622733769885549555429595981
- 6461284125481523641339765370
- 66950973792848320411792499601
- 692878680960562864969363384910
- 7162360810346449261192969637028
- 73958269462680913376461650794152
- 762919205903660944920523210661377
- 7862462356803215299533205007813806
- 80956434902985402104622557703016977
- 832874061781047994819672246576419514
- 8561758460942363424315837377300688366
- 87947013526805356793864093102783600499
- 902757327901213687376081267798908754616
- 9260377915106116852616564230637740582108
- 94931186568893878451195580899916418846736
- 972579864870501412683269238042780744028743
- 9958420807622547975400738352360988337988344
|