Padovan n-step number sequences: Difference between revisions

m
Line 1,497:
loop do
yield sum = ar[..-2].sum
ar.shift if ar.size > n_step
ar << sum
end
Line 1,503:
 
t = 15
(2..8).each do |n|
print "N=#{n} :"
puts "%5d"*t % padovan(n).take(t)
end
</syntaxhighlight>
Line 1,517:
N=8 : 2 3 5 8 13 21 34 54 87 140 225 362 582 936 1505
</pre>
 
=={{header|Rust}}==
<syntaxhighlight lang="rust">
1,149

edits