Shape-Machine
Shape-Machine is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task
- Get user input and store in a variable/stack
- Add 3 to the input and multiply it by 0.86 and then output it
- Now reapeat the previos step
See Also
Python
a=int(input()) while True: a += 3 a *= 0.86 print(a)
Raku
my $input = (+prompt()).FatRat;
my $previous = 0.FatRat;
my $count;
my $places = 36;
loop {
$input += 3;
$input ×= .86;
last if $previous.substr(0,$places) eq $input.substr(0,$places);
++$count;
say ($previous = $input).substr(0,$places);
}
say "$count repetitions";
- Output with a 4 fed in at the prompt:
4 6.02 7.7572 9.251192 10.53602512 11.6409816032 12.591244178752 13.40846999372672 14.1112841946049792 14.715704407360282112 15.23550579032984261632 15.6825349796836646500352 16.066980082527951599030272 ... many, many lines omitted ... 18.428571428571428571428571428571416 18.428571428571428571428571428571418 18.428571428571428571428571428571419 18.428571428571428571428571428571420 18.428571428571428571428571428571421 18.428571428571428571428571428571422 18.428571428571428571428571428571423 18.428571428571428571428571428571424 512 repetitions