개발/개발 자료

입력된 숫자까지의 소수 구하기

시원한물냉 2013. 9. 10. 12:27
import java.util.Scanner;

public class Sosusum {
public static void main(String[] args) {

System.out.println("입력돈 숫자까지의 소수 구하기");
System.out.print("입력 : ");
int inNum = 0;

Scanner scan = new Scanner(System.in);

inNum = scan.nextInt();

// ------------------------------
// 입력된 숫자까지의 소수 구하기
// ------------------------------
for (int i = 2; i <= inNum; ++i) {
for (int j = 2; j <= inNum; ++j) {
if (i % j == 0) {
if (i == j)
System.out.print(i + " ");
else
break;
}
}
}

}

}