Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class PrimeCalculatot {
- public static boolean isPrime(int n){
- for (int i = 2; i <= (int)Math.sqrt(n); i++){
- if (n % i == 0)
- return false;
- }
- return true;
- }
- public static void main(String[] args){
- int n;
- Scanner sc = new Scanner(System.in);
- n = sc.nextInt();
- for (int i = 2; i <= n; i++){
- if (isPrime(i))
- System.out.println(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement