Shape-Machine: Difference between revisions
Content deleted Content added
No edit summary |
Added Algol 68 |
||
Line 3:
==See Also==
* [https://esolangs.org/wiki/Shape-Machine Esolangs.org page]
=={{header|ALGOL 68}}==
===Non-terminating===
{{Trans|Python}}
<syntaxhighlight lang="algol68">
BEGIN
REAL a := BEGIN INT n; read( n ); n END;
DO
print( ( fixed( a +:= 3 *:= 0.86, -16, 14 ), newline ) )
OD
END
</syntaxhighlight>
===Terminating after successive values converge===
Based on Raku, using 64-bit floating point.
<syntaxhighlight lang="algol68">
BEGIN
REAL a := BEGIN INT n; read( n ); n END;
REAL prev a := IF a = 0 THEN 1 ELSE 0 FI;
INT count := 0;
WHILE prev a /= a
DO
count +:= 1;
prev a := a;
print( ( fixed( a +:= 3 *:= 0.86, -16, 14 ), newline ) )
OD;
print( ( whole( count, 0 ), " repetitions" ) )
END
</syntaxhighlight>
{{out}}
With 4 as the input
<pre>
6.02000000000000
7.75720000000000
9.25119200000000
10.5360251200000
11.6409816032000
12.5912441787520
13.4084699937267
14.1112841946050
...
18.3988095846536
18.4029762428021
18.4065595688098
...
18.4285714285714
18.4285714285714
18.4285714285714
231 repetitions
</pre>
=={{header|Python}}==
a=int(input())
|