आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
Core Java - Factorial Of Number

विवरण :

कोई विवरण नहीं है |


सोर्स कोड :

import java.util.Scanner;

public class Factorial
{
public static void main(String args[])
{
int a,fact;

System.out.println("Enter the number : ");
Scanner enter = new Scanner(System.in);
a = enter.nextInt();

fact=factorial(a);

System.out.println("Factorial of " + a + " is " + fact);
}

static int factorial (int x)
{
int f;
if(x==1){
return (1);
}
else{
f=x*factorial(x-1);
}
return(f);
}
}

आउटपुट :

Enter the number : 
5
Factorial of 5 is 120