How to check if two series of dates overlap and determine the first date that it occurs?
问题 How to check if two series of dates overlap and determine the first date that it occurs? Imagine that I've created two events in Google Calendar. One of them in Date1 and repeating every X days; the other in Date2 and repeating every Y days. What would be the best algorithm to determine if the two series will overlap someday, and find the first date that it would happen? Example 1: Date1 = Feb-15, 2016 X = 14 (repeat every 14 days) Date2 = Feb-22, 2016 Y = 21 (repeat every 21 days) Result: