Wednesday, 11 November 2020

Java Program to Print Factorial of a Number entered by the user

 /* The factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n */

import java.util.*;

public class FACTORIAL

{

        void Find()

    {

        Scanner in=new Scanner(System.in);

        int N,f=1,i;

        System.out.println("Enter a Number to find its Factorial");

        N=in.nextInt();

        for(i=1;i<=N;i++)

        f=f*i;

        System.out.println("The factorial of "+N+" is : "+f);

    }

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...