簡體   English   中英

階乘顯示已經運行但未在 eclipse 中運行

[英]Factorial Showing already Running but not running in eclipse

我是初學者,沒有足夠的知識。 當我運行階乘時,它顯示已經運行但不要求值或顯示任何錯誤。

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);

    }

}

考慮添加一個打印語句,例如 System.out.print("Enter the value:"),然后您就會明白發生了什么。 如果該語句未顯示在 output 中,請檢查您的 ide 是否運行良好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM