Skip to content

Conversation

@momstrosity
Copy link
Owner

@momstrosity momstrosity commented May 8, 2025

Feature: Implement Robust Prime Number Checker

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 robust is_prime() function
  • Developed comprehensive test suite in tests/test_prime_checker.py
  • Added necessary error handling and input validation

Implementation Details

  • Function: is_prime(number)
    • Efficiently checks primality using square root method
    • O(√n) time complexity for primality check
    • Handles special cases (0, 1, negative numbers)

Input Validation

  • Checks for integer type
  • Raises TypeError for non-integer inputs
  • Raises ValueError for negative numbers
  • Returns False for 0 and 1

Testing Approach

  • Comprehensive test coverage including:
    • Known prime numbers
    • Known non-prime numbers
    • Large prime and non-prime numbers
    • Edge cases (0, 1, negative numbers)
    • Invalid input type handling

Test Results

  • 6/6 tests passed
  • 100% coverage of input scenarios
  • Verified correct primality identification

Acceptance Criteria

  • Correctly identifies prime numbers
  • Handles edge cases (0, 1, negative numbers)
  • Provides clear error messages
  • Efficient implementation
  • Comprehensive test coverage

Performance Considerations

  • Uses square root optimization for primality check
  • Minimal computational overhead
  • Suitable for both small and large number checks

Notes

  • Requires Python 3.7+
  • Minimal dependencies (only pytest for testing)

Changes Made

  • Implemented prime number checking logic in src/prime_checker.py
  • Created comprehensive test suite in tests/test_prime_checker.py
  • Added input validation and error handling
  • Optimized primality checking algorithm

Tests

  • Verify correct identification of prime numbers
  • Check handling of edge cases (0, 1)
  • Test negative number input
  • Validate error handling for invalid input types
  • Performance testing for large numbers
  • Comprehensive coverage of prime and non-prime scenarios

Signatures

Staking Key

AEghvdqmRtc3fjKXfNTMJJ6WshksgWuJ9YBExgsZu8cN: 34UaFkLyVBNNacyjBw3E29LoLs7LzXY8ZNJ389FC3Lpt6ZLgkPaKpyM1zrP5DuMqqVFoLwJ44rZrEHmTTVemdu2xkp3ttyiYj77femaL4iCUbNfimNTdc3fXuvnCTuLGPFqz7wzuGxNchTbe24BGfB8nHokMxKQNiPm4x9zoxpAq9ZCCsk6GXm7kJbhYDmhejk4pJQRJDmSeZE7ya2kGcS1SuvSQViG8gdQeVRogJhWS7hJHF7BNK6YQQ8bNasLYJ9QM6qrx46JVk4KBsvsfPKYr6LaVVAq8y2KU4LAkrnUAWVuiVZYwGHhk2xEtMrwiokUghbcebWvcz2vUhpwVQbnThGdhr7hFtvJ5GyfDvT6zZonLXSMUVTH1GtDarmcytcrgz4oTemmeWtrYtskw9LHQLWsX9JoVsp2Q

Public Key

AwXAtX7tMhL4JyB8NfXdsrqc1UifaMyap3c9bpN9RMse: 2DLF9w5Jmw8CjkDzXrrURKWHrQSi53iaE34jGTTMFu96212MomK8cE9MmjBRcnGpv3vz6ceS3QAQ5BSM1QQet6nTiJP5z7qvxDmojzwf2H1wKFnj4G9CiUr8v2UkU6f6ZJk5venWC2gZr8G6pPTkmHn6Z4xVdayR5zdQ15TRAZTBKzuECRbpC33ccRm4bGDJXQEQQCy61oYSdjx29tdHQYRt5Cy6vXPd9RQzd5PXBp4axJVRF6N8xekkAG7gjkrfnGA69L5BxxZhkJS9b1zKZ6fX4xcHveWt75aaXsVKbLTBENVBQ1uKm2p9bBoC4ggXqQMtMcWefeceD334AS1JWFrDa8phta4MYi9Bo6jKcAHwvSEUzF9EBYoqsU6cPK5GczAGWLod8imcNPhTVcKyZ9suouWtcUnSeUXn

@momstrosity momstrosity changed the title [WIP] Implement Prime Number Checker Function Feature: Implement Robust Prime Number Checker May 8, 2025
@momstrosity momstrosity marked this pull request as ready for review May 8, 2025 17:33
momstrosity pushed a commit that referenced this pull request May 22, 2025
…265e59-merged

Robust Mathematical Utilities: Prime Operations and GCD Optimization
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