Skip to content

Instantly share code, notes, and snippets.

@neiraza
Created May 2, 2012 03:40
Show Gist options
  • Save neiraza/2573405 to your computer and use it in GitHub Desktop.
Save neiraza/2573405 to your computer and use it in GitHub Desktop.
素数ください
import java.util.ArrayList;
public class Hoge {
public static void main(String[] args){
int num = Integer.parseInt(args[0]);
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i=2;i<=num;i++){
boolean isPrime=true;
for(int j=2;j<=i;j++){
if(j!=i && i%j==0){
isPrime = false;
continue;
}
}
if(isPrime){
list.add(i);
}
}
System.out.println(list.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment