- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Includes
Certificate & Practice Material
Programs for practice
In the program below, we've introduced beginers to programming in java
Source Code: find factorial of a given number
# This program find factorial of a given number (5! = 5*4*3*2*1)
class Factorial{
public static void main(String args[]){
int i,fact=1,n;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number to find factorial: ");
n = sc.nextInt();
for(i=1;i<=n;i++){
fact=fact*i;
}
System.out.println("Factorial of "+n+" is: "+fact);
}
}
Output
Enter a number to find factorial: 4
factorial of a is 24