Skip to content

Conversation

@Varshap2205
Copy link

@Varshap2205 Varshap2205 commented Jan 8, 2026

Description of Change

Changed the loop condition in is_prime() from i * i <= num to i <= num / i to prevent potential integer overflow for large values of num.

The logic of the algorithm remains the same, and all primes and non-primes are correctly identified. Tested with edge cases: 2, 3, 5, 9, 25, 121.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

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.

1 participant