Answer to Question #157658 in Java | JSP | JSF for hj

Question #157658

Write an application that displays the factorial for every integer value from 1 to 10. A factorial of a

number is the product of that number multiplied by each positive integer lower than it. For

example, 4 factorial is 4 * 3 * 2 * 1, or 24.


1
Expert's answer
2021-01-22T11:45:59-0500
public static void main() {
  int result = 1;
  for(int i = 1; i <= 10; ++i) {
      result = result * i;
      System.out.println("Factorial of " + i + " is " + result);
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog