Skip to content

Conversation

@momstrosity
Copy link
Owner

@momstrosity momstrosity commented May 8, 2025

Implement Robust Prime Number Checker Function

Description

Task

Implement Prime Number Checker

Acceptance Criteria

  • Function should return boolean indicating if number is prime
  • Implement efficient primality test
  • Handle edge cases (negative numbers, 0, 1)
  • Include unit tests for various cases

Summary of Work

Prime Number Checker Implementation

Changes Made

  • Created src/prime_checker.py with a comprehensive is_prime() function
  • Implemented thorough test suite in tests/test_prime_checker.py

Implementation Details

Function: is_prime(number)

  • Performs primality checking for integer inputs
  • Handles edge cases and input validation
  • Uses efficient trial division algorithm with square root optimization

Key Features

  1. Input Validation

    • Raises TypeError for non-integer inputs
    • Returns False for numbers <= 1
    • Efficiently checks primality for positive integers
  2. Algorithmic Approach

    • Uses trial division method
    • Checks divisibility up to square root of the number
    • Provides O(√n) time complexity

Test Coverage

  • Tested prime and non-prime numbers
  • Validated edge cases (0, 1, negative numbers)
  • Checked large prime and non-prime numbers
  • Comprehensive type checking and error handling

Acceptance Criteria

✓ Correctly identifies prime numbers
✓ Handles edge cases (0, 1, negative numbers)
✓ Provides clear error handling
✓ Implements efficient primality checking
✓ Comprehensive test suite

Notes

  • Function optimized for performance and readability
  • Follows Python best practices for type checking and error handling

Changes Made

  • Implemented is_prime() function in src/prime_checker.py
  • Added comprehensive test cases in tests/test_prime_checker.py
  • Ensured robust error handling and input validation
  • Implemented efficient primality checking algorithm

Tests

  • Verify identification of prime numbers
  • Check handling of non-prime numbers
  • Test edge cases (0, 1, negative numbers)
  • Validate input type checking
  • Confirm error handling for invalid inputs

Signatures

Staking Key

AEghvdqmRtc3fjKXfNTMJJ6WshksgWuJ9YBExgsZu8cN: 3PzheUQPqMqBndpY6xY2fHsiLz8Y3yDBcLDMWTMLRwYjqJRxjnxX3u9HXBcvubEeXJ7WF2DF7X9Es77fHEGp8R6gcquYS3HRXVvjioeUTtb9PwTGma5ef96JaWEJVZZEERzQEJZHs6B2RkCmA3AMJFWfaJ62EdG8ygrVFc3Znkd4kbRbn8rCpN26K4oJ7NS3dDUg299M7WmXDu895xyHhxK644yTHLvvaWsuFf79nuZrYZ6dLbCpecWQGj8GgLq9wdkPyrgwsZonydNK7c5ehdXoSLtKoKnHRQycC9ExUwP3biccagz3ov5wWSnXsnrkktwNBXLZo5QWgnfnups1tyQmQy6FGxBgVXQ9wNRCauDmb7YYCGiLcB4PqXkpJohw6pPEXXpZbgnd2xG7kShYkPYCSAbQxrRcigWQ

Public Key

AwXAtX7tMhL4JyB8NfXdsrqc1UifaMyap3c9bpN9RMse: 2ofyVjS6dSwt9Skys4S3JgS9Ptu6n4bFVr2zFj1MeymHW5G6apTzzDvAyPQMmRgyXtbfmfAqHAoB3JUvVwwP8maMNRWjLHSKsCyuWwqW8AkahthCtwhK1RDe1Lfq3P1gG3YZYBZaoNxHjRYPaRKgD7fJSTCEE2dTCifta1YQri948VbY6xVRXfDUxQVqhGdbvxfMRsNLZD8GQeJJhTGpk9e6kbosPD69pTXviu8VvDdkMBVQLVkyECwwAkd7BcGraWaDJdCsSuZJ1oewMUPQmyVqjQMjdneCcaLbWUBhDgDT5cWK23mPi3zqeo9UFXWsHykx1eMUikWotpCAAqmAVHzkWKTXXirHoURwuz8WsYyCCCSmu5z18XP1kvAL84TDaXAfjRXTsRjpxLeZhyQhpA8Q3wAhxYWbwP32

@momstrosity momstrosity changed the title [WIP] Implement Prime Number Checker Function Implement Robust Prime Number Checker Function May 8, 2025
@momstrosity momstrosity marked this pull request as ready for review May 8, 2025 16:59
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