Free Puzzle Questions with Answer using Java, C#, JavaScript and PHP

Java Quiz - Find Factorial

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package find.factorial;

import java.util.Scanner;

/**
 *
 * @author Bereket
 */
public class FindFactorial {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print("Please enter any number");
        
        int givenNumber = scanner.nextInt();
        
        long factorial = 1;
        for(int i=1; i<= givenNumber; i++){
            factorial = factorial * i;
            
        }
        
        System.out.println("The factorial of " + givenNumber + " is " + factorial);
    }
    
}