简体   繁体   中英

Factorial Showing already Running but not running in eclipse

I am very beginner not having enough knowledge. When I am running factorial its showing already running but not asking for value or showing any error.

package loops;

import java.util.Scanner;
public class Factorial {
    public static void main(String[] args) {

        Scanner sc= new Scanner (System.in);

int n = sc.nextInt();
 int factorial = 1;
 for(int i = n; i>=1; i--) {
 factorial = factorial * i;
    }
    System.out.println(factorial);

    }

}

Consider adding a print statement like, System.out.print("Enter the value:"), then you'll understand what's happening. If the statement doesn't shows up in the output, check that your ide is running fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM