Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] returnPrime(int max) //doesn't work
- {
- int tally = 0;
- boolean notPrime= false;
- for(int i = 1; i<max; i++) {
- for(int j = 1; j<max; j++) {
- if(i%j != 0) {
- notPrime = true;
- }
- }
- if(notPrime = false) {
- tally++;
- }
- }
- int[] a = new int[tally];
- for(int i = 1; i<max; i++) {
- for(int j = 1; j<max; j++) {
- if(i%j != 0) {
- notPrime = true;
- }
- }
- if(notPrime = false) {
- a[tally-1]=i;
- tally--;
- }
- }
- return a;
- }
- public static main (String[] args){
- int[] prime = returnPrime(10000);
- for(int i = 0; i<prime.length;i++) {
- System.out.println(prime[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement