Program
import java.util.*; class Factorial { int fact(int x) { if(x>1) return x*fact(x-1); else return x; } public static void main(String[] args) { int a,c; Factorial F1=new Factorial(); Scanner S=new Scanner(System.in); System.out.println("Enetr an integer value"); a=S.nextInt(); c=F1.fact(a); System.out.println("Factorial is:" +c); } }
Post A Comment:
0 comments: