package test;
import java.util.Scanner;
import static java.lang.System.out;
public class TestClass {
public static int numOfFactors(int n, int s, int e) {
int factors = 0;
for(int i = s; i<=e; i++) {
while(n%s==0) {
factors = factors + 1;
}
}
return factors;
}
public static void main(String[] args) {
TestClass test = new TestClass();
System.out.println(test.numOfFactors(100,10,30));
}
}
這是我的程式碼,想在s,e區間中找到n的因數個數。但在使用Eclipse編譯的過程中,
run完都沒有結果產生(印出簡單的Hello World是成功的)。自己覺得是使用method的方法有誤,但在找完網路上的資料試過,
都不太清楚是什麼地方有誤,想請問大大們@@