How to resolve the algorithm Padovan sequence step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Padovan sequence step by step in the J programming language
Table of Contents
Problem Statement
The Padovan sequence is similar to the Fibonacci sequence in several ways. Some are given in the table below, and the referenced video shows some of the geometric similarities. Show output here, on this page.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Padovan sequence step by step in the J programming language
Source code in the j programming language
padovanSeq=: (],+/@(_2 _3{]))^:([-3:)&1 1 1
NB. or, equivalently:
padovanSeq=: (, [: +/ _2 {. }:)@]^:([ - 2:)&1 1
realRoot=. {:@(#~ ]=|)@;@p.
padovanNth=: 0.5 <.@+ (realRoot _23 23 _2 1) %~ (realRoot _1 _1 0 1)^<:
padovanL=: rplc&('A';'B'; 'B';'C'; 'C';'AB')@]^:[&'A'
seqLen=. #@(-.&' ')"1
padovanSeq 20
1 1 1 2 2 3 4 5 7 9 12 16 21 28 37 49 65 86 114 151
(padovanSeq 64) -: padovanNth(i.64)
1
padovanL i.10
A
B
C
AB
BC
CAB
ABBC
BCCAB
CABABBC
ABBCBCCAB
(padovanSeq 32) -: seqLen padovanL i.32
1
You may also check:How to resolve the algorithm Array concatenation step by step in the Stata programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the VBA programming language
You may also check:How to resolve the algorithm Monads/Writer monad step by step in the Jsish programming language
You may also check:How to resolve the algorithm SHA-1 step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Ackermann function step by step in the AWK programming language