Answer the question
In order to leave comments, you need to log in
How to work with BigInteger correctly?
Good afternoon, ladies and gentlemen.
Tell me how to work with comparison operators in BigInteger?
import java.util.Scanner;
import java.math.*;
public class CalcBig
{
public static void main(String[] args)
{
System.out.print("Введите любое целое число: ");
Scanner scan = new Scanner(System.in);
BigInteger number = scan.nextBigInteger();
BigInteger factorial = CalcBig.fact(number);
System.out.print(factorial);
}
private static BigInteger fact(BigInteger number)
{
if (number <= 0)
{
return BigInteger.valueOf(1);
}
else
{
return number * fact(number-1);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question