Sylvester's sequence: Difference between revisions
Content deleted Content added
Added Prolog solution |
→{{header|ALGOL 68}}: Corrected spelling of reciprocal - thanks to Gerard Schildberger for showing me the error of my ways... |
||
Line 25:
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
Uses Algol 68G's LONG LONG INT and LONG LONG REAL which have specifiable precision. The sum of the
<lang algol68>BEGIN # calculate elements of Sylvestor's Sequence #
PR precision 200 PR # set the number of digits for LONG LONG modes #
Line 44:
# find the first 10 elements of Sylvestor's Seuence #
[]LONG LONG INT seq = SYLVESTOR 10;
# show the sequence and sum the
LONG LONG REAL
FOR i FROM LWB seq TO UPB seq DO
print( ( whole( seq[ i ], 0 ), newline ) );
OD;
print( ( "Sum of
END
</lang>
Line 65:
12864938683278671740537145998360961546653259485195807
165506647324519964198468195444439180017513152706377497841851388766535868639572406808911988131737645185443
Sum of
</pre>
|