import java.io.*;
class Factorial1 {
int fact(int n)
{
 if(n==1) 
System.out.println(1);
else
return (fact(n-1) * n);
}
}


public class Recursion11 {
public static void main(String args[]) 
{
Factorial1 f = new Factorial1();
System.out.println("Factorial of 3 is " + f.fact(3));
System.out.println("Factorial of 4 is " + f.fact(4));
System.out.println("Factorial of 5 is " + f.fact(5));
}
}

java :9:missing return statement }

Where is the return for the true condition of the if statement?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.