Skip to content

Instantly share code, notes, and snippets.

@Quantalabs
Last active May 25, 2020 20:18
Show Gist options
  • Save Quantalabs/df5449b368dfb04ecd21b6a957c6eaf2 to your computer and use it in GitHub Desktop.
Save Quantalabs/df5449b368dfb04ecd21b6a957c6eaf2 to your computer and use it in GitHub Desktop.
Outputs numbers in the Padovan Sequence. Modify the variable "amount" to change amount of numbers outputede. Read more on the Pardovan Sequence at https://en.wikipedia.org/wiki/Padovan_sequence
var list = [1,1,1] //changing these values to [3,0,2] will output the perrin sequence
var amount = 7 //changing this value will change the amount of numbers outputed.
for(var i = 0; i < amount-3; i++) { //chaning the number that is subtracted from 'amount' is the original length of list
var j = list[i];
var e = list[i+1];
list.push(j+e)
}
console.log(list) //change to 'document.body.innerHTML = list' to show on webpage or append to a div or paragraph if needed
@Quantalabs
Copy link
Author

This version doesn't work. Will Fix

@Quantalabs
Copy link
Author

Fixed. Updating soon!

@Quantalabs
Copy link
Author

Updated

@Quantalabs
Copy link
Author

Missed Semicolons in For Loop. Just updated that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment