Write a Java Program Factorial Number /** Compute the Factorial of n, where n=20. * n! = 1*2*3*...*n */ public class Factorial { public static void main(String[] args) { int n = 20; // To compute factorial of n int factorial = 1; // Init the product to 1 int i = 1; while (i <= n) { factorial = factorial * i; i++; } System.out.println("The Factorial of " + n + " is " + factorial); } } Set an Initial Breakpoint Start Debugger Right click anywhere on the source code (or from the "Run" menu) ⇒ "Debug As" ⇒ "Java Application" ⇒ choose "Yes" to switch into "Debug" perspective (A perspective is a particular arrangement of panels to suits a certain development task such as editing or debugging). Step-Over and Watch the Variables and Outputs & Breakpoint, Run-To-Line, Resume and Terminate
Comments
Post a Comment