Asked by Mr. Anonymous
To whoever helped me ealier (or anybody period), need some more help on where to go
Here’s the question once again:
I need to write a code in java based on an alrgorithm, the alrgorithm and it’s problem are below:
The Sieve of Eratosthenes is “a simple, ancient algorithm for finding all prime numbers up to any given limit,” which you can read about at: (Wikipedia: Sieve of Eratosthenes)
Write a method called sieve that takes an integer parameter, n , and returns a boolean array that indicates, for each number from 0 to n – 1, whether the number is prime.
Here’s what I got so far:
public static boolean sieve(int n) {
for (int i = n; i > n; i--) {
if (n%2 == true){
i = false
}
}
return true;
}
Here’s the question once again:
I need to write a code in java based on an alrgorithm, the alrgorithm and it’s problem are below:
The Sieve of Eratosthenes is “a simple, ancient algorithm for finding all prime numbers up to any given limit,” which you can read about at: (Wikipedia: Sieve of Eratosthenes)
Write a method called sieve that takes an integer parameter, n , and returns a boolean array that indicates, for each number from 0 to n – 1, whether the number is prime.
Here’s what I got so far:
public static boolean sieve(int n) {
for (int i = n; i > n; i--) {
if (n%2 == true){
i = false
}
}
return true;
}
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.