Friday, June 10, 2016

solution for n! in java using BigInteger Class

import java.util.Scanner;
import java.math.BigInteger;
class Main
{
// standard Java class name in UVa OJ
    public static void main(String[] args)
    {
        int n;
        Scanner sc= new Scanner(system.in);
        n=sc.nextInt;
        BigInteger fac = BigInteger.ONE;
        for (int i = 2; i <=n; i++)
            fac = fac.multiply(BigInteger.valueOf(i));
// it is in the library!
        System.out.println(fac);
    }
}

No comments:

Post a Comment

Speedup Android Studio

Go to Help ->Edit Custom VM Options, and chnge this 4 setting. After that close your Android Studio. This settings are for 8gb of ram pc...