Base case is wrong for n==0. it will display stackoverflow

public class Factorial {
public static void main(String[] args) {
	int n=5;
	System.out.println(fact(n));

}
public static int fact(int n) {
	if(n==1)
		return 1;
	return n*fact(n-1);
		
}

}

This code is correct? for all n>=0???

@Vipin_coder
Yes its Correct
0 ke liye nhi chalega

base case is wrong for n==0 , once compile it.base case must be if(n==0||n==1) return 1

kbse yhe bol rha hu n==0 pr stackoverflow ayega ,base case if(n==0||n==1) return 1 hona chyie , aap bol rhe h n pr kabhi janunga ni 1 return kr dega 0 hoga to , pta ni kaise krgea ,maine to aaj tk kabhi ni padha aisa

if you want to include 0
then its correct

@Vipin_coder
Sorry for this may be ye read nhi kiya ho

I hope confusion is clear
Please mark your doubts as resolved in your course’s.

ya, you can also read my doubt title.