Tagged: 

  • Factorial

     Indu updated 1 month ago 2 Members · 2 Posts
  • Akash 

    Administrator
    at

    Write a program for factorial.

  • Indu

    Member
    at

    import java.util.Scanner;

    public class Factorial {

    public static void main(String []args){

    Scanner Scan=new Scanner(System.in);

    System.out.println(“Enter the number”);

    int n=Scan.nextInt();

    int fac=1;

    for(int i=1;i<=n;i++){

    fac=fac*i;

    }

    System.out.println(“Factorial of the given number is : “+fac);

    }

    }

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 21st September 2020. Attend one week free demo classes.Register Now

New Report

Close