Padovan sequence: Difference between revisions

no edit summary
(Added clojure version.)
No edit summary
Line 1,501:
64 35676949 35676949
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>ClearAll[Padovan1,a,p,s]
p=N[Surd[((9+Sqrt[69])/18),3]+Surd[((9-Sqrt[69])/18),3],200];
s=1.0453567932525329623;
Padovan1[nmax_Integer]:=RecurrenceTable[{a[n+1]==a[n-1]+a[n-2],a[0]==1,a[1]==1,a[2]==1},a,{n,0,nmax-1}]
Padovan2[nmax_Integer]:=With[{},Floor[p^Range[-1,nmax-2]/s+1/2]]
Padovan1[20]
Padovan2[20]
Padovan1[64]===Padovan2[64]
SubstitutionSystem[{"A"->"B","B"->"C","C"->"AB"},"A",10]//Column
(StringLength/@SubstitutionSystem[{"A"->"B","B"->"C","C"->"AB"},"A",31])==Padovan2[32]</lang>
{{out}}
<pre>{1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151}
{1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151}
True
A
B
C
AB
BC
CAB
ABBC
BCCAB
CABABBC
ABBCBCCAB
BCCABCABABBC
True</pre>
 
=={{header|Nim}}==
1,111

edits