package com.kapish;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// WAP to find whether a given number is prime or not.
Scanner sc= new Scanner(System.in); //System.in is a standard input stream.
System.out.print("Enter first number- ");
int eno = sc.nextInt();
System.out.println(eno);
int i,fact=1;
int number=eno;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i;
}
System.out.println("Factorial of "+number+" is: "+fact);
}
}
No comments:
Post a Comment