Han ROM tower

let step = 1
// Move n plates from A to C, with the help of B
function t(n, start, b, end) {
  if(n == 1) {
    console.log(step++, start, '-->', end)
  } else {
    t(n-1, start,end,b) //
    console.log(step++, start, '-->', end)
    t(n-1, b,start,end)
  }
}
// t(1,'A', 'B', 'C')
t(3.'A'.'B'.'C')
Copy the code

Fibonacci numbers

Starting with the third term, each term in the Fibonacci sequence equals the sum of the first two terms: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34…

function fb(n){
    if (n == 1 || n==2) {
    	return 1
    }
        
    return fb(n-1)+fb(n-2)}console.log(fb(9)) 
/ / 34
Copy the code

N factorial

function js(num){
    if(num<=1) return 1;
    else{
        return num * js(num-1); }}Copy the code

update

.Copy the code