Skip to content

Conversation

@momstrosity
Copy link

Implement Prime Number Checker Function with Comprehensive Testing

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

Overview

This pull request implements a robust Prime Number Checker function with comprehensive testing and error handling.

Changes Made

  • Created src/prime_checker.py with is_prime() function
  • Implemented efficient prime number detection algorithm
  • Added comprehensive test suite in tests/test_prime_checker.py

Implementation Details

Prime Number Checker Function (src/prime_checker.py)

  • Uses optimized algorithm to check primality
  • Handles input validation:
    • Checks for integer type
    • Validates positive number range
  • Efficiently checks divisibility up to square root of number
  • Handles special cases like 1, 2, and 3

Test Suite Features (tests/test_prime_checker.py)

  • Covers various test scenarios:
    1. Known prime numbers
    2. Known non-prime numbers
    3. Large prime and non-prime numbers
    4. Invalid input type handling
    5. Invalid input range handling

Testing Approach

  • Used PyTest for comprehensive test coverage
  • Implemented multiple test cases to validate function behavior
  • Verified edge cases and error conditions
  • Ensured 100% test pass rate

Acceptance Criteria

✓ Correctly identifies prime and non-prime numbers
✓ Handles input validation
✓ Provides clear error messages
✓ Efficient implementation
✓ Comprehensive test coverage

Notes

  • Time complexity: O(√n)
  • Optimized for performance and readability

Changes Made

  • Created src/prime_checker.py with is_prime() function
  • Implemented input validation and type checking
  • Added efficient primality checking algorithm
  • Created tests/test_prime_checker.py with comprehensive test cases
  • Verified all tests pass successfully

Tests

  • Verify identification of prime numbers
  • Verify identification of non-prime numbers
  • Test large prime and non-prime numbers
  • Validate input type handling
  • Validate input range handling
  • Ensure all tests pass without errors

Signatures

Staking Key

AEghvdqmRtc3fjKXfNTMJJ6WshksgWuJ9YBExgsZu8cN: iAJxHxnh9MKhg4k27ff2ApawZHzKog3oBeJUkcuK4XVSGmf3o4ejFKsBaMGQYvSgkJuHG1YnmZVMjB1UWAP22CbmvYCCa2Lpz67ZJT9hmLXvJvGnbpZCWaJrqPdGXHJmBpfW6JEJsNHDew2cKsoP5Qs8Vz4MoGH6mcTN7fqq1PwJAd4Zob2MnpAxJ4sqb8qWc37ZZ4nMqAdZSLJdWEBNqscLietfw9TWt6w6M7tpad8iTzTv26upTU6Xvirho42ogLYVaYupESap4NTw8B5niEudd8Wcu1DCGGKTqpqgvjWZth1epF9YNjEYc29PB9SR3Qk6gqqdGfmZWPujG4a76RNaGxwHrHd8LbGNwMqtZxqVQLLk4XZ4zJKvDd1iDRajuLXWEaGXarPDy5zRgfoM8V29qpQoPopS4qS

Public Key

AwXAtX7tMhL4JyB8NfXdsrqc1UifaMyap3c9bpN9RMse: 34HD37q7pZxomwP6zQdctETvDmREeYyPtKY51QtKA3zbCgPpMwwSPv8AjJ4KJuxuYqfs1zfdXRg4kw4iKjdv4AF2dL3KsgSpK3jE17KG9ypwHn8VHFsNYrnQKXqDKGj3X6ExUzRZomVqzsr75zhuTr6U7TeoDbaMWAS7KG2VL8GsN4jFJgZZ1gzG2DAGAcqKMKMgFTc1kMxLjH9VnNvB6Rp5sjD2Ukhni4GqTCr1Ar1VPyoexd3wArHRxToLVKUDAsS6vh66oXSSAzWByLB6w9vqnA2R7v6KnXkKVGzU5cUCtq4i1X7NL9PqryPDjrQtn245vjYB2piGHSNdUpAz3AFFFcL4t8Pp7CUyijngQnJGE2jQAWQdjo8T7DGwts91SuUXfb58HQ1YQBtXombwr8HKxUYuBFr5MiUU

laura-abro added a commit that referenced this pull request Apr 11, 2025
momstrosity added a commit to momstrosity/builder-test that referenced this pull request Apr 11, 2025
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