Padovan sequence: Difference between revisions
Content added Content deleted
(→{{header|ALGOL 68}}: Compute and compare the correct number of terms of the sequences) |
m (→{{header|ALGOL 68}}: Correct "off-by-one" comments) |
||
Line 69: | Line 69: | ||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
<lang algol68>BEGIN # show members of the Padovan Sequence calculated in various ways # |
<lang algol68>BEGIN # show members of the Padovan Sequence calculated in various ways # |
||
# returns the first |
# returns the first n elements of the Padovan sequence by the # |
||
# recurance relation: P(n)=P(n-2)+P(n-3) # |
# recurance relation: P(n)=P(n-2)+P(n-3) # |
||
OP PADOVANI = ( INT n )[]INT: |
OP PADOVANI = ( INT n )[]INT: |
||
Line 79: | Line 79: | ||
p |
p |
||
END; # PADOVANI # |
END; # PADOVANI # |
||
# returns the first |
# returns the first n elements of the Padovan sequence by # |
||
# computing by truncation P(n)=floor(p^(n-1) / s + .5) # |
# computing by truncation P(n)=floor(p^(n-1) / s + .5) # |
||
# where s = 1.0453567932525329623 # |
# where s = 1.0453567932525329623 # |
||
Line 95: | Line 95: | ||
result |
result |
||
END; # PADOVANC # |
END; # PADOVANC # |
||
# returns the first |
# returns the first n L System strings of the Padovan sequence # |
||
OP PADOVANL = ( INT n )[]STRING: |
OP PADOVANL = ( INT n )[]STRING: |
||
BEGIN |
BEGIN |