Given a natural number A, I want to find all the pairs of natural numbers (B,C) so that B*C*(C+1) = A

后端 未结 3 1490
情书的邮戳
情书的邮戳 2021-02-06 08:45

What\'s the fastest way to do it?

My simple aproach:

for (C = 1;C

        
3条回答
  •  日久生厌
    2021-02-06 09:20

    It can be done in O(cube_root(A))
    Indeed, one of your numbers B and C must be less than cube_root(A)

提交回复
热议问题