Recursion-1 > bunnyEars

We have a number of bunnies and each bunny has two big floppy ears. We want to compute the total number of ears across all the bunnies recursively (without loops or multiplication).

bunnyEars(0) → 0
bunnyEars(1) → 2
bunnyEars(2) → 4


public int bunnyEars(int bunnies) {
  if(bunnies==0)
   return 0;


  else
   return 2+ bunnyEars(bunnies-1);

}

Recursion-1 > factorial

Given n of 1 or more, return the factorial of n, which is n * (n-1) * (n-2) ... 1. Compute the result recursively (without loops).

factorial(1) → 1
factorial(2) → 2
factorial(3) → 6

Solution
public int factorial(int n) {
  
  if(n==1 || n==0)
   return 1;
  else
   return n*factorial(n-1);
}

How to hide generated javascript file in visual studio code

In this post I am going to show you a cool trick in visual studio code. Let's suppose you are writing typescript code in visual studio code and you want to hide generated javascript code.

Create .vscode folder in your folder and then create settings.json file and paste following code

{
    "files.exclude": {
        "node_modules":true,
        "**/.git"true,
        "**/.DS_Store"true,
        "**/*.js.map"true,
        "**/*.js": {"when""$(basename).ts"}
    }
}