Problem 52990. Easy Sequences 46: Semi-prime Leap Year Pairs
A semi-prime is a positive integer that has only 2 and exactly 2 prime factors. Here is a list of the first few semi-primes:.
We define a Semi-prime Leap Year Pair as a pair of years, whose difference is a semi-prime number and at least one year in the pair is a leap year. Examples of semi-prime leap year pairs are: , , and .
Given a year number y, write a program that counts the number of semi-prime leap year pairs between year and y, inclusive.
NOTE: Leap years are defined as those years that are divisible by 4, except for those that ends in , in which case a year is a leap year only if it is divisible by . This rule was introduced only starting . Before , the rule is much simpler, namely, except for , all years that are multiples of 4, are leap years. Please apply the appropriate rule for each year. Also, please assume that there will not be any more leap year definition changes in the future.
EXAMPLE: For , the semi-primes are: , and the leap years are: . Therefore the semi-prime leap year pairs for this case are as follows:
Therefore, in this case the function should return: pairs.
Solution CommentsShow comments
Problem Recent Solvers2