- 773 名前:デフォルトの名無しさん mailto:sage [2007/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"); } } }
|

|