11 comments:

  1. import java.util.Scanner;

    class Test{

    public static void main(String ar[])
    {

    Scanner sc=new Scanner(System.in);
    int num,loop=1,factorial=1;
    System.out.println("Enter Number to find Factorial");
    num=sc.nextInt();
    while (loop <= num)
    {
    factorial=factorial*loop;
    loop++;
    }
    System.out.println("Factorial = "+factorial);

    }
    }

    ReplyDelete
  2. import java.util.Scanner;

    class Factorial
    {

    public static void main(String ar[])
    {
    int num,fac=1;
    System.out.print("Enter the number: ");
    Scanner o= new Scanner(System.in);
    num=o.nextInt();

    while(num>=1)
    {
    fac*=num;
    num--;
    }
    System.out.print("The factorial is: "+fac);

    }
    }

    ReplyDelete
  3. import java.util.Scanner;
    class Factorial
    {
    public static void main(String ar[])
    {
    int Number,Fact=1,j;
    Scanner scan=new Scanner(System.in);
    System.out.println("Enter the Number you want to calculate its Factorial");
    Number=scan.nextInt();
    while(Number>1)
    {
    Fact=Fact*(Number*(Number-1));
    Number=Number-2;
    }
    System.out.println(Fact);
    }
    }

    ReplyDelete
  4. import java.util.Scanner;
    class Factorial
    {
    public static void main(String Args[])
    {
    System.out.println(" enter the number");
    Scanner sc=new Scanner(System.in);
    int fact=sc.nextInt();
    int num=1;
    while(fact>1)
    {
    num*=fact;
    fact--;
    }
    System.out.println("factorial is"+num);
    }
    }

    ReplyDelete
  5. 14.
    import java.util.Scanner;
    public class JavaApplication6 {


    public static void main(String[] args) {

    Scanner obj=new Scanner(System.in);
    int num;
    num=obj.nextInt();
    int fact=1;
    for(int i=1;i<=num;i++)
    {
    fact=fact*i;
    }
    System.out.println("The factorial of the number is="+fact);
    }
    }

    ReplyDelete
  6. import java.util.Scanner;
    class factorial
    {
    public static void main(String ar[])
    {
    Scanner sc = new Scanner(System.in);
    float num , i, factorial =1;
    System.out.println("enter the number");
    num = sc.nextFloat();
    i=1;
    while(i<=num)
    {
    factorial *= i;
    i++;
    }
    System.out.println(" the factorial are : " +factorial);
    }
    }

    ReplyDelete
  7. import java.util.Scanner;
    class Factorial{
    public static void main(String ar[]){
    Scanner obj=new Scanner(System.in);
    int num,i=1,fact=1;
    System.out.println("enter the value of number");
    num=obj.nextInt();
    while(i!=num+1){
    fact=fact*i;
    i++;
    }
    System.out.println("factorial of the given is "+fact);
    }

    }

    ReplyDelete
  8. import java.util.Scanner;
    class Factorial{
    public static void main(String ar[]){
    int number,answer=1;
    Scanner scan=new Scanner(System.in);
    System.out.println("Enter the number");
    number=scan.nextInt();
    while(number>1){
    answer=answer*number;
    number--;
    }
    System.out.println("factorial of number is = "+answer);
    }
    }

    ReplyDelete
  9. import java.util.Scanner;

    class Factorial{
    public static void main(String ar[]){
    int n,fact=1;
    Scanner scan=new Scanner(System.in);
    System.out.println("Enter the number:");
    n=scan.nextInt();

    while(n>=1){
    fact=fact*n;
    n--;
    }
    System.out.println("The factorial is:"+fact);
    }
    }

    ReplyDelete
  10. import java.util.*;

    class Fact{
    public static void main(String ar[]){
    Scanner s= new Scanner(System.in);
    int n,fact=1;
    System.out.print("enter the number: ");
    n=s.nextInt();
    while(n>0)
    {
    fact*=n;
    n--;
    }
    System.out.print("The factorial is: "+fact);

    }
    }

    ReplyDelete
  11. package com.example.myapplication;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;

    public class Factorial extends Activity {
    int num,count,fact=1;
    Button btfact;
    EditText etfact;
    TextView tvfact;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.factorial);

    btfact=findViewById(R.id.btfact);
    etfact=findViewById(R.id.etfact);
    tvfact=findViewById(R.id.tvfact);

    btfact.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    num=Integer.parseInt(etfact.getText().toString());
    for (count=1;count<=num;count++) {

    fact = fact * count;
    }
    tvfact.setText("Result="+fact);
    }

    });
    }
    }

    ReplyDelete