Skip to content

Add PrimeNumberUtils with isPrime and getPrimesUpTo methods #6371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Naveenkumarsuk
Copy link

Summary

Added PrimeNumberUtils class in the math/ folder.

What It Does

  • Checks if a number is prime
  • Returns a list of all prime numbers up to a given value
  • Optimized with Math.sqrt() and skips even numbers

Sample Output

This utility is helpful for math learners and coding interview prep.
Let me know if you'd like to see test cases too!

@alxkm
Copy link
Contributor

alxkm commented Jul 12, 2025

Each algorithm should be in a separate branch.

And it looks like they are all already in this repository.

Prime numbers checker located here: https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/maths/Prime/PrimeCheck.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants