Want to know:
Use Sieve of Eratosthenes algorithm public int countPrimes(int n) { boolean[] isPrime = new boolean[n]; for(int i = 2; i < n; i++) { isPrime[i] = true; } for(int i = 2; i * i < n; i++) { if(!isPrime[i]) { continue; } else { for(int j= i * i; j < n; j += i) { isPrime[j] = false; } } } int counter = 0; for(int i = 2; i < n; i++) { if(isPrime[i]) { counter++; } } return counter; }
Get a detailed, AI-powered explanation for this question and thousands more on StudyFetch.
Get the Answer for FreeHow StudyFetch Helps You Master This Topic
AI-Powered Answers
Get instant, detailed explanations powered by AI that understands your course material.
Deep Understanding
Go beyond surface-level answers with step-by-step breakdowns and examples.
Personalized Learning
Spark.E adapts to your learning style and helps you connect ideas.
Practice & Test
Turn any question into flashcards, quizzes, and practice tests to solidify your knowledge.
Explore More Questions
- Lire, comprendre et essayer de faire les exemple sur les antibiotiques et les angioplasties
- Addressing the business, technological, and organizational issues associated with creating, maintaining, and making changes to a system.
- 13) Which of the following is at the top of the management structure for information systems projects in a large company?A) Project teamB) Project management groupC) Corporate strategic planning group and information systems steering committeeD) Information systems managersE) End-user managers