Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can anyone Modify then Explain the below code? import java.util.Scanner; import java.math. * ; public class LargeFactorial { public static void main ( String [

can anyone Modify then Explain the below code?
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

Students also viewed these Databases questions

Question

Write a paper on "Why is Data Important?"

Answered: 1 week ago

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago