Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.PrintStream;
- public class PrimeFinder {
- int start;
- int stop;
- int cnum;
- public void main (String args[]) {
- start = 2450;
- stop = 2504;
- if (stop>=start) { throw new IllegalArgumentException("Interval is 0 or less"); }
- for (cnum=start; cnum!=stop; cnum++) {
- if (checkprime(cnum)) {
- System.out.println(cnum);
- }
- }
- }
- private boolean checkprime(int num) {
- int i;
- for (i=2; i <= (Math.sqrt(num)+1); i++) {
- if ((num % i)!=0) {
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement