Skip to content

Conversation

@momstrosity
Copy link
Owner

@momstrosity momstrosity commented May 22, 2025

Implement Efficient 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

  • Implemented is_prime() function in src/prime_checker.py
  • Added comprehensive prime number detection algorithm
  • Included robust error handling and input validation

Implementation Details

  • Algorithm uses optimized prime checking approach
  • Time complexity: O(sqrt(n))
  • Handles edge cases including:
    • Negative numbers
    • Zero and one
    • Large prime and non-prime numbers
    • Invalid input types

Key Features

  • Efficiently checks primality by:
    • Skipping even numbers after 2
    • Checking divisibility only up to square root
    • Handling special cases first
  • Raises TypeError for non-integer inputs
  • Supports both small and large number checks

Testing Approach

  • Comprehensive test suite covering:
    • Known prime numbers
    • Known non-prime numbers
    • Large prime and non-prime numbers
    • Negative number handling
    • Input type validation

Test Results

  • All 6 test cases passed successfully
  • 100% coverage of specified test scenarios
  • Validates function correctness and robustness

Acceptance Criteria Met

  • ✓ Efficient prime number detection
  • ✓ Handles various input scenarios
  • ✓ Comprehensive error handling
  • ✓ Passes all provided test cases

Considerations

  • Further optimization possible for extremely large numbers
  • Current implementation provides a balance between efficiency and readability

Changes Made

  • Implemented prime number checking algorithm
  • Added comprehensive input validation
  • Optimized for performance
  • Included detailed docstring
  • Handled edge cases thoroughly

Tests

  • Verified detection of prime numbers
  • Tested non-prime number identification
  • Checked large prime number recognition
  • Validated handling of edge cases
  • Ensured proper error handling for invalid inputs

Signatures

Staking Key

AEghvdqmRtc3fjKXfNTMJJ6WshksgWuJ9YBExgsZu8cN: N8te2ZJT1ywci3HzrVkB5a7TghdhkqQirwpNCaTJJQuXvcejq3UYFbMmx1FNgJUhTJPAFdzZAeHi2qtUFEwfCGWvKQ9qSmJMZnJoLwTM8SZtzEKiijwMV17burHRykZG4UkcseQjuxnR7Fx9PeBYMSd6MxnhMRBJX9u1Sj5jxZ3pBcvisrNfySjsSKFHafjEoS8dxTrQvmXo9VQh34nPuRB6FSqVFKhexpv14wwfRCRLKSzHpBsJoYdZ2b8CaF2tmfS8R2c2Gx3x1XNkQLv5AxdPjtTyHdArgoDCSbFScBFqsRoiZsim8Vfyc4trZBMhotF8CUHTYKRy62Tcr9oH28AQqvNaj74GWyKDpjoZ2BAZfN5ph5Atq5urvE1Mb85UQ5vexTHnqfUjQqm8DYYibDJuhFSpmVZRCha

Public Key

AwXAtX7tMhL4JyB8NfXdsrqc1UifaMyap3c9bpN9RMse: vT2a22q4QEfeYjwiuNYUUaKFbUMKTVNjjPH1rpy7EKG6n6ytRHqQWkK6qeMgwSAjKwjeF4vu5e6AKP5UoyDqrnWNVg3vmjaBmTm22eeNKdMdgvMG8etUuMXG4TSsBhL3dtWg1SnjJJFTex9u6NEVEP2BpDuWGDbcURktgKrVyxUrkGpd2T4KyT4bLj8VNjTV3pYhR7T6xbfFEnEC8LdjVdYtuYKtiHNzzrU3MTicNgxUxivcjec7jGeYDWbytpiM3ViPAKF8YX51h8PZtsm5Qq7TpFWwjPVr5mreLWj4rRWYWYNZWd4qYSr2KYywyQ1xtzTcuNzyfArf9CYjkPBKKKoygKCwER36Dtc3tVLX1rWX266GgPLqF6UuJdtro6Ka71uyoqBgu6V1j4KHPcHYuQWVHZXif4dSnKE

@momstrosity momstrosity changed the title [WIP] Implement Prime Number Checker Function Implement Efficient Prime Number Checker Function May 22, 2025
@momstrosity momstrosity marked this pull request as ready for review May 22, 2025 17:26
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.

4 participants