Created
January 29, 2018 18:25
-
-
Save mingbackmountain/582904c9db9555d1e1191d8b8e926717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Oldcode { | |
private static boolean prime[] = new boolean[1000000]; | |
private static int n; | |
public static void delete(int i) { | |
for (int index = i+1; index < n; ++index) { | |
if(index%i == 0) { | |
prime[index] = false; | |
} | |
} | |
} | |
public static void main(int argc,String argv) { | |
Oldcode.n = Integer.parseInt(argv); | |
for (int i = 2; i <= n; i++) { | |
prime[i] = true; | |
if(prime[i]==true) { | |
delete(i); | |
} | |
} | |
for(int i = 2;i<=n;i++) { | |
if(prime[i]==true) { | |
System.out.println(i); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment