Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; import java.math. * ; public class LargeFactorial { public static void main ( String [ ] args ) { Scanner input = new

import java.util.Scanner;
import java.math.*;
public class LargeFactorial {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter an integer: ");
int n = input.nextInt();
System.out.println(n +"! is
"+ factorial(n));
}
public static BigInteger factorial(long n){
BigInteger result = BigInteger.ONE; // Assign 1 to result
for (int i =1; i <= n; i++)// Multiply each i
result = result.multiply(new BigInteger(i+""));
return result;
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

What methods are used for cascading: default versus freedom?

Answered: 1 week ago

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago

Question

Question How are IRAs treated for state tax law purposes?

Answered: 1 week ago