Not passing the test cases

Code:

public class Main {
static int factorial(int n) {
int f;

  for(f = 1; n > 1; n--){
     f *= n;
  }
  return f;

}
static int ncr(int n,int r) {
return factorial(n) / ( factorial(n-r) * factorial® );
}
public static void main(String args[]){
System.out.println();
int n, i, j;
n = 5;

  for(i = 0; i <= n; i++) {
     for(j = 0; j <= n-i; j++){
        System.out.print(" ");
     }
     for(j = 0; j <= i; j++){
        System.out.print("\t"+ncr(i, j));
     }
     System.out.println();
  }

}
}

Please use the online IDE to submit the code like this.

Your logic was correct but you had error in the output format. Pay close attention to the expected output format. I have updated your code as per the required output format, you can refer to it after trying again

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.