Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,35 @@
// Calculate the $n'th Fibonacci number
// Set this to how many in the sequence to generate
$n = 10;
// These are what hold the current calculation
$a = 0;
$b = 1;
// This holds the complete sequence that is generated
$sequence = "";
// Prepare a loop
$i = 0;
:calcnextnumber;
$i = $i++;
// Do the calculation for this loop iteration
$b = $a + $b;
$a = $b - $a;
// Add the result to the sequence
$sequence = $sequence << $a;
// Make the loop run a fixed number of times
if $i < $n; {
$sequence = $sequence << ", ";
goto calcnextnumber;
}
// Use the loop counter as the placeholder
$i--;
// Return the sequence
return = "Fibonacci number " << $i << " is " << $a << " (" << $sequence << ")";