Skip to content

Conversation

@mike-turintech
Copy link
Member

This pull request introduces significant optimizations and improvements to the Primes class. Key changes include:

  • Imports Updated: Switched from java.util.Vector to java.util.ArrayList for better performance and flexibility.

  • Optimized Prime Checking: The IsPrime method now checks for primality up to the square root of n, reducing unnecessary iterations and removing redundant checks.

  • Adjusted SumPrimes Method: The loop in SumPrimes now starts at 2, and the sum operation has been simplified for clarity.

  • Enhanced PrimeFactors Method: Updated to return an ArrayList<Integer> and optimized the logic to find prime factors using a while loop, including a check for n itself as a prime factor if applicable.

These changes collectively enhance the efficiency of prime checking and factorization processes, reduce time complexity for larger inputs, and improve code readability and maintainability.

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.

3 participants