[PYTHON] This year's prime numbers

I checked this year's prime numbers with python.

def is_prime(n):
    if n == 1:
        return None
    elif n == 2: 
        return True
    elif n >=3 :
        num_max = int(math.sqrt(n))
        for i in range(2, num_max+1):
            if n % i == 0:
                return False
        return True       
import math
year = 2020
for month in range(1,13):
    day_max = -1
    if month in [2]:
        if year % 400 == 0:
            day_max = 29
        elif year % 100 == 0:
            day_max = 28
        elif year % 4 == 0:
            day_max = 29
        else:
            day_max = 28
    elif month in [4,6,9,11]:
        day_max = 30
    else:
        day_max = 31
    
    for d in range(1,day_max+1):
        serial = year * 10000 + month * 100 + d
        if is_prime(serial):
            print(serial)

20200109 20200111 20200121 20200123 20200223 20200309 20200429 20200511 20200529 20200613 20200619 20200703 20200711 20200721 20200723 20200729 20200801 20200813 20200903 20201021 20201029 20201101 20201113 20201227 20201231

It seems that there are 25 times this year.

Recommended Posts

This year's prime numbers
Prime numbers and divisors
Recursively find prime numbers
Prime numbers in Python
Determine prime numbers with python
Project Euler 10 "Sum of Prime Numbers"
It's a prime number ... Counting prime numbers ...
[Python] nCr mod Compute prime numbers
Algorithm learned with Python 4th: Prime numbers
I searched for prime numbers in python