my first code

Upload: bjun-curada-loreto

Post on 09-Jan-2016

219 views

Category:

Documents


0 download

DESCRIPTION

my frist code

TRANSCRIPT

/* This is my favorite code for this is my first code in learning java and this means a lot to me Java Factorial Example This Java Factorial Example shows how to calculate factorial of a given number using Java.*/ public class NumberFactorial { public static void main(String[] args) { int number = 5; /* * Factorial of any number is !n. * For example, factorial of 4 is 4*3*2*1. */ int factorial = number; for(int i =(number - 1); i > 1; i--) { factorial = factorial * i; } System.out.println("Factorial of a number is " + factorial); }} /*Output of the Factorial program would beFactorial of a number is 120*/