Day 10Is It Prime?

    Easymathloops

    Write is_prime(n) that returns True if n is a prime number and False otherwise.

    A prime is a whole number greater than 1 whose only divisors are 1 and itself: 2, 3, 5, 7, 11, ...

    Examples

    Example 1
    >>> is_prime(7)
    True
    Example 2
    >>> is_prime(10)
    False
    Example 3
    >>> is_prime(1)
    False

    Good to know

    • n can be 0, 1 or negative (none of those are prime), and as large as a few billion.

    Run examples checks the 3 examples above. Submit runs all 10 tests, including hidden edge cases, and marks the challenge solved.

    solution.py
    Loading Python…

    Test results show up here

    Write is_prime in the editor, then run the examples. Use print() freely: its output is shown for each test.