Numbers with equal rises and falls: Difference between revisions
Numbers with equal rises and falls (view source)
Revision as of 17:59, 10 October 2020
, 3 years ago→{{header|Raku}}: Generalize further
Thundergnat (talk | contribs) (Add a related task) |
Thundergnat (talk | contribs) (→{{header|Raku}}: Generalize further) |
||
Line 786:
use Base::Any;
sub rf (int $base = 10, $batch = Any, &op = &infix:<==>) {
my %batch = batch => $batch if $batch;
my int ($this, $last) = $_, $_ % $base;
my int ($rise, $fall) = 0, 0;
Line 798:
$last = $rem
}
next unless &op($rise
$_
}
}
# The task
my $upto = 200;
put "
.put for rf[^$upto]».fmt("%3d").batch(20);
$upto = 10_000_000;
put "\nThe {$upto.&
# Other bases and comparisons
$upto = ^6;▼
put "\n\nGeneralized for other bases and other comparisons:";
put "\n{tc $upto.map({.exp(10).&ordinal}).join: ', '}, values in some other bases:";▼
put "\nRise = Fall: $which";
for <3 296691 4 296694 5 296697 6 296700 7 296703 8 296706 9 296709 10 296712
11 296744 12 296747 13 296750 14 296753 15 296756 16 296759 20 296762 60 296765>
->
put "Base {$base.fmt(<%2d>)} (https://oeis.org/A$oeis): ",
$upto.map({rf(+$base, Any)[.exp(10) - 1].&to-base($base)}).join: ', '
}
put "\nRise > Fall: $which";
for <3 296692 4 296695 5 296698 6 296701 7 296704 8 296707 9 296710 10 296713
11 296745 12 296748 13 296751 14 296754 15 296757 16 296760 20 296763 60 296766>
->
put "Base {$base.fmt(<%2d>)} (https://oeis.org/A$oeis): ",
$upto.map({rf(+$base, Any, &infix:«>»)[.exp(10) - 1].&to-base($base)}).join: ', '
}
put "\nRise < Fall: $which";
for <3 296693 4 296696 5 296699 6 296702 7 296705 8 296708 9 296711 10 296714
11 296746 12 296749 13 296752 14 296755 15 296758 16 296761 20 296764 60 296767>
-> $base, $oeis {
put "Base {$base.fmt(<%2d>)} (
$upto.map({rf(+$base,
}</lang>
{{out}}
<pre>
First two hundred (base 10):
1 2 3 4 5 6 7 8 9 11 22 33 44 55 66 77 88 99 101 102
103 104 105 106 107 108 109 111 120 121 130 131 132 140 141 142 143 150 151 152
Line 846 ⟶ 853:
381 382 383 384 385 386 387 390 391 392 393 394 395 396 397 398 401 402 403 404
The
Generalized for other bases and other comparisons:
Rise = Fall: First, tenth, one hundredth, one thousandth, ten thousandth, values in some other bases:
Base 3 (https://oeis.org/A296691): 1, 201, 22112, 10101111, 1100022001
Base 4 (https://oeis.org/A296694): 1, 111, 3333, 221012, 13002120
Base 5 (https://oeis.org/A296697): 1, 102, 1441, 40011, 1431201
Base 6 (https://oeis.org/A296700): 1, 55, 512, 20424, 400402
Base 7 (https://oeis.org/A296703): 1, 44, 365, 12620, 155554
Base 8 (https://oeis.org/A296706): 1, 33, 316, 7466, 60404
Base 9 (https://oeis.org/A296709): 1, 22, 275, 5113, 40217
Base 10 (https://oeis.org/A296712): 1, 11, 252, 3396, 29201
Base 11 (https://oeis.org/A296744): 1, A, 216, 2240, 21718
Base 12 (https://oeis.org/A296747): 1, A, 201, 10AA, 19723
Base 13 (https://oeis.org/A296750): 1, A, 1B8, A0A, 172A7
Base 14 (https://oeis.org/A296753): 1, A, 1B5, 8B9, 14B81
Base 15 (https://oeis.org/A296756): 1, A, 1B2, 7D4, 11BBA
Base 16 (https://oeis.org/A296759): 1, A, 1A9, 716, 10424
Base 20 (https://oeis.org/A296762): 1, A, 196, 523, 8011
Rise > Fall: First, tenth, one hundredth, one thousandth, ten thousandth, values in some other bases:
Base 3 (https://oeis.org/A296692): 12, 1222, 122202, 12222001, 2001200001
Base 4 (https://oeis.org/A296695): 12, 233, 12113, 1003012, 13131333
Base 5 (https://oeis.org/A296698): 12, 122, 2302, 112013, 1342223
Base 6 (https://oeis.org/A296701): 12, 45, 1305, 20233, 333134
Base 7 (https://oeis.org/A296704): 12, 34, 1166, 11612, 140045
Base 8 (https://oeis.org/A296707): 12, 26, 1013, 4557, 106756
Base 9 (https://oeis.org/A296710): 12, 25, 348, 2808, 36781
Base 10 (https://oeis.org/A296713): 12, 24, 249, 2345, 23678
Base 11 (https://oeis.org/A296745): 12, 23, 223, 1836, 15806
Base 12 (https://oeis.org/A296748): 12, 1B, 166, 1623, 12534
Base 13 (https://oeis.org/A296751): 12, 1B, 145, 149B, A069
Base 14 (https://oeis.org/A296754): 12, 1B, 12B, 1393, 6BC9
Base 15 (https://oeis.org/A296757): 12, 1B, 11A, 12B7, 568E
Base 16 (https://oeis.org/A296760): 12, 1B, CD, 1206, 466A
Base 20 (https://oeis.org/A296763): 12, 1B, 7E, 6BF, 2857
Base 60 (https://oeis.org/A296766): 12, 1B, 2i, Lp, 66U
Rise < Fall: First, tenth, one hundredth, one thousandth, ten
Base 3 (https://oeis.org/A296693): 10, 221, 22220, 10021001, 1012110000
Base
Base
Base
Base
Base
Base
Base
Base
Base
Base
Base
Base
Base
Base
Base
▲Base 60 (OEIS:A296765): 1, A, ff, 1f2, 63Q, g5D</pre>
=={{header|REXX}}==
|