yaptrick's blog

By yaptrick, history, 23 hours ago, In English

hi,

could anyone help me with the following problem?

find the number of pairs (x,y) for which 1<=x,y<=10^7 and gcd(x,y) = x xor y

here are my thoughts: we can let x=da and y=db for coprime a,b then we must have a XOR b = 1 i.e. a and b are consecutive integers. how do we proceed from here

thanks!

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
23 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

sorry :(

»
23 hours ago, # |
  Vote: I like it 0 Vote: I do not like it
»
23 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

probably $$$O(n ~log~ n)$$$ soln

Code
  • »
    »
    23 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    oops i miscalculated, apparently da xor db does not necessarily equal d(a xor b). thanks for the help though

»
10 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

seems no solution lower than $$$O(n\log n)$$$?