Arithmetic derivative P86263


Statement
 

pdf   zip

Given a natural number nn, its arithmetic derivative d(n)d(n) is defined as follows:

  • d(0)=d(1)=0d(0) = d(1) = 0.

  • If nn is prime, then d(n)=1d(n) = 1.

  • Let n=xyn = x \cdot y, with 1<x,y<n1 < x, y < n. Then d(n)=xd(y)+yd(x)d(n) = x \cdot d(y) + y \cdot d(x).

For instance, d(4)=2d(2)+2d(2)=2+2=4d(4) = 2d(2) + 2d(2) = 2 + 2 = 4, and d(6)=3d(2)+2d(3)=3+2=5d(6) = 3d(2) + 2d(3) = 3 + 2 = 5. It can be proven that this definition is consistent. For example, d(12)=4d(3)+3d(4)=4+12=16d(12) = 4d(3) + 3d(4) = 4 + 12 = 16, and also d(12)=6d(2)+2d(6)=6+10=16d(12) = 6d(2) + 2d(6) = 6 + 10 = 16.

We say that ff is a fixed point of d(n)d(n) if d(f)=fd(f) = f. For instance, 0 and 4 are fixed points. Given \ell and rr, can you compute the number of fixed points of d(n)d(n) in [..r][\ell..r]?

Input

Input consists of several cases, each one with \ell and rr, with 0r10180 \le \ell \le r \le 10^{18}.

Output

For each case, print the number of fixed points of d(n)d(n) in [..r][\ell..r].

Public test cases
  • Input

    0 4
    1 20
    4 4
    5 23
    900000000000000000 1000000000000000000
    

    Output

    2
    1
    1
    0
    0
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++