This page is still under construction.

Parts of this page are still being built. What you see may change.

Sanggeun's Idea

Time limit2sMemory limit128 MB

Summary
Compute the sum of gcds over all pairs of values 2^(2^n)+1 for n from n1 to n2.
Level

Medium7 of 10

Topics
Number theory, Combinatorics
Solved
No attempts yet

Problem

Sanggeun gave his son the following problem.

Two integers n1n_1 and n2n_2 satisfy 1≤n1<n2≤1041 \le n_1 < n_2 \le 10^4. Let N∗\mathbb{N}^* be the set of positive integers and define p:N∗→N∗p:\mathbb{N}^* \rightarrow \mathbb{N}^* by p(n)=2np(n) = 2^n for every n∈N∗n \in \mathbb{N}^*. This function defines the set SS.

S(n1,n2)={p(p(n))+1∣n1≤n≤n2}S(n_1,n_2)=\left\{ p(p(n))+1 \mid n_1 \le n \le n_2 \right\}

The set of pairs built from the elements of SS is defined as well.

T(n1,n2)={(m1,m2)∣m1,m2∈S(n1,n2), m1<m2}T(n_1,n_2)=\left\{ (m_1,m_2) \mid m_1,m_2 \in S(n_1,n_2),\ m_1 < m_2 \right\}

Now define the value

R(n1,n2)=∑(m1,m2)∈T(n1,n2)gcd⁡(m1,m2)R(n_1,n_2)=\sum_{(m_1,m_2) \in T(n_1,n_2)} \gcd(m_1,m_2)

where gcd⁡(m1,m2)\gcd(m_1,m_2) is the greatest common divisor of m1m_1 and m2m_2.

Given n1n_1 and n2n_2, write a program that computes R(n1,n2)R(n_1,n_2).

Input

The first line contains two integers n1n_1 and n2n_2 separated by a space. (1≤n1<n2≤1041 \le n_1 < n_2 \le 10^4)

Output

Print the value of R(n1,n2)R(n_1,n_2) on the first line.

Examples2

  1. Example 1

    Input
    1 34
    
    Expected output
    561
    
  2. Example 2

    Input
    1 2
    
    Expected output
    1