Anonymous user
Sylvester's sequence: Difference between revisions
m
→{{header|REXX}}: added whitespace and a comment.
(Added Sidef) |
m (→{{header|REXX}}: added whitespace and a comment.) |
||
Line 621:
parse arg n . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n= 10 /*Not specified? Then use the default.*/
numeric digits max(9, 2**(n-7) * 13 + 1)
@.0= 2 /*the value of the 1st Sylvester number*/
$= 0
Line 629:
$= $ + 1 / @.j /*add its reciprocal to the recip. sum.*/
end /*j*/
say /*stick a fork in it, we're all done. */
numeric digits digits() - 1
say 'sum of the first ' n " reciprocals using" digits() 'decimal digits: ' $ / 1</lang>
{{out|output|text= when using the default inputs:}}
|