Sequences everywhere

4

19 votes
Mathematics, Hard
Problem

Let's consider some integer X. We will call the following sequence S a sequence generated by X:

  1. for i = 1: S[i] = X
  2. for i > 1: S[i] equals to the minimal positive integer such that S[i] is not a divisor of S[i - 1]. If there is no such integer than S[i - 1] is the last element of S.

For example S = (10, 3, 2) is a sequence generated by 10.

Can you find the total sum of lengths of the sequnces generated by all the integers from A to B inclusive.

Input
The only line contains two integers: A and B. (A <= B)

Output
Output the only integer - answer to the question. It's guaranteed that this value can be stored in 64-bit integer.

Constraints
1 < A <= B <= 1017

Subtasks

  • B - A <= 106 in 30% of test data.
Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?