How to resolve the algorithm Padovan sequence step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Padovan sequence step by step in the Quackery 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 Quackery programming language

Source code in the quackery programming language

( --------------------- Recurrence -------------------- )
 
  [ dup 0 = iff
     [ drop ' [ ] ] done
    dup 1 = iff
      [ drop ' [ 1 ] ] done
   dip [ [] 0 1 1 ]
   2 - times 
       [ dip [ 2dup + ] swap 
         3 pack dip join 
         unpack ]
     3 times join behead drop ] is padovan1 ( n --> [   )
 
  say "With recurrence:     " 20 padovan1 echo cr cr
 
 
( ------------------- Floor Function ------------------ )
 
  $ "bigrat.qky" loadfile
 
  [ [ $ "1.324717957244746025960908854"
      $->v drop join ] constant 
    do ]                        is p        (   --> n/d )
 
  [ [ $ "1.0453567932525329623"
      $->v drop join ] constant 
    do ]                        is s        (   --> n/d )
 
  [ 1 -
    p rot v** s v/ 1 2 v+ / ]   is padovan2 ( n --> n   )
 
  say "With floor function: "
  []
  20 times [ i^ padovan2 join ]
  echo cr cr
 
 
( ---------------------- L-System --------------------- )
 
  [ $ "" swap witheach 
      [ nested quackery join ] ]    is expand ( $ --> $ )
 
  [ $ "B" ]                         is A      ( $ --> $ )
 
  [ $ "C" ]                         is B      ( $ --> $ )
 
  [ $ "AB" ]                        is C      ( $ --> $ )
 
  $ "A"
 
  say "First 10 L System strings: "
  9 times 
    [ dup echo$ sp
      expand ]
  echo$ cr cr
 
  [] $ "A"
  31 times
    [ dup size
      swap dip join
      expand ]
  size join
  
  32 padovan1 = iff
    [ say "The first 32 recurrence terms and L System lengths are the same." ]
  else [ say "Oh no! It's all gone pear-shaped!" ]

  

You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the ML/I programming language
You may also check:How to resolve the algorithm Parsing/Shunting-yard algorithm step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Smarandache-Wellin primes step by step in the J programming language
You may also check:How to resolve the algorithm O'Halloran numbers step by step in the PROMAL programming language
You may also check:How to resolve the algorithm Literals/Integer step by step in the V (Vlang) programming language