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 Stats

50.0% Correct | 50.0% Incorrect
Last Solution submitted on Mar 08, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers2

Suggested Problems

More from this Author116

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!