- Posted By: pradeeshtet
- Comments: 0

This type of questions are asked in technical round of the interview, to confuse the fresher and test his/her programming skill. Program to display factorial of first N numbers. Here is tutorial for finding factorial of a single integer using recursion method.

First read the number upto which the factorial should be found. Implementing for loop to iterate and display the result.

what is factorial, Factorial of a number 4 is 4*3*2*1 i.e 24. So the factorial of 4 is 24.

class factorialP{ public static void main(String[] args) { int fact; int factval; for(int i=1;i <=10;i++) { fact=i; factval=1; if(fact==1) { System.out.println(fact); } else { while(fact>1) { factval= factval*fact; fact --; } System.out.println(factval); } } } }