Last active
February 28, 2020 09:52
-
-
Save shcyiza/eb5e2cdcfad27b5fd5d71d2fe2c3c0ac to your computer and use it in GitHub Desktop.
tail recurssion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// some jusque | |
// Method de accumulateur | |
function som_till(n,A=0){ | |
if(n<0){ | |
return A; | |
} | |
return som_till(n-1,n+A) | |
} | |
console.log(`som from all int from 0 till 6 is ${som_till(6)}`) | |
// fubonacci | |
// Method de DEUX accumulateurs!!!! trop fort poto!!!! | |
function fub(n, A0=0, A1=1){ | |
if(n<=0){ | |
return 0; | |
} | |
if(n<=1){ | |
return A1; | |
} | |
return fub(n-1, A1, A0+A1) | |
} | |
console.log(`14th fubonacci number is ${fub(14)}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well done Bro. Une petite amelioration: