Goodstein Sequence: Difference between revisions
Content deleted Content added
m →gmp version: grammer |
added Raku programming solution |
||
Line 432:
Term 16 of Goodstein(16): 2771517379996516970665566613559367879596937714713289695169887161862950129194382447127464877388711781205972046374648603545513430106433206876557475731408608398953667881600740852227698037876781766310900319669456854530159244376159780346700931210394158247781113134808720678004134212529413831368888355854503034587880113970541681685966414888841800498150131839091463034162026108960280455620621355407543489960326268155088833218122810217973039385643494213235664908254695964740257569988152978579630435471016976693529875691083071137361386386918409765002837648351746984484967203877495399596876291343126699827442908994036031608979805166915596436929638418152127561722561465793969723556331679336828840983098559789555364076924597258115780567651772009250336359472037679350612341393780002377587368649157608579801815531133644879180066181854487069796160774056572568941004114162614925
</pre>
=={{header|Raku}}==
{{trans|Phix}}
<syntaxhighlight lang="raku" line># 20240219 Raku programming solution
sub bump($n is copy, $b) {
loop ( my ($res, $i) = 0, 0; $n.Bool or return $res; $i++ ) {
if my $d = ($n % $b).Int { $res += $d * (($b+1) ** bump($i,$b)).round }
$n = ($n / $b).floor
}
}
sub goodstein($n, $maxterms = 10) {
my @res = $n;
while @res.elems < $maxterms && @res[*-1] != 0 {
@res.push(bump(@res[*-1], (@res.elems + 1)) - 1)
}
return @res
}
say "Goodstein(n) sequence (first 10) for values of n from 0 through 7:";
for 0..7 -> $i { say "Goodstein of $i: ", goodstein($i) }
say();
my $max = 16;
say "The Nth term of Goodstein(N) sequence counting from 0, for values of N from 0 through $max :";
for 0..$max -> $i { say "Term $i of Goodstein($i): {goodstein($i, $i+1)[*-1]}" }</syntaxhighlight>
You may [https://ato.pxeger.com/run?1=XZK_btswEMaBjnqKr4YaUJas2ktTWElRdCm6eMpWdPAfyiIqkQ5FtjUMPUmXDM0LZczT9I5SXTkaCIj33Xe_O97vP3b93T88PHpXzt4_v3pq_QYb3xxErKFabM3hmCHeJDhFAGpjDhBojhCxlS1FVIJbzDPMC8Q6_2RMDWNhpfNWgzV0r9IUgwF9quT8eEd5XOQNu-dftMMp6JHecnAKIeJNukgwnQ5AKiNlklvj9Q7d4EYOvc_b4FMSoeVQF3VRxM3sjdm1TipNIuJt1r-ctE1LWYv5AEU4H7kyFdYFX_ysVC3DXS5rSeKbUeLVVYh8nc4W3_Camj93FhIOvq1EAD6rMoiRV4pFkmBGZ89JxzAuFgXs9RGTz2dunaCV917qrYQolW1dQC9pzj_WtSdwU0KjtKYhGFfRgPYVrpeTImLNPM-vMftAz0ATvrTmxFgtMcnGY6In7SFEUkT8VNQ6j-td0ZPdVRIrV4HHwQ7_SVcj0i09k1N6P3BlL3hXL3lDlRFz-L_AvuN69HtRkmiXOI3peSlpb8Lkuwm6frWHDf-36X8B Attempt This Online!]
=={{header|Wren}}==
|