★★ Java の宿題ここ ..
773:デフォルトの名無しさん
07/07/06 21:59:35
ごめん根本的なとこ勘違いしてた14793は素数じゃない
public class IsPrime{
public static void main(String[] args){
try{
int n = Integer.parseInt(args[0]);
boolean[] b = new boolean[n + 1];
for(int i = 2; i * i <= n; i++){
for(int j = 1; j * i <= n; j++){
b[i * j] = true;
}
}
if(!b[n])
System.out.println(Integer.toString(n) + " is Prime.");
}catch(Exception e){
System.err.println("Usage IsPrime N");
}
}
}
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4178日前に更新/337 KB
担当:undef