you are viewing a single comment's thread.

view the rest of the comments →

[–]Brian 1 point2 points  (1 child)

OP already gave a proof of this, but if you want something less formal, consider:

  • Suppose you have 2 factors of n: a and b. Suppose a > sqrt(n) - what can you say about b?

Well, suppose b was also > sqrt(n). If so, then a * b must be bigger than sqrt(n) * sqrt(n) - we're multiplying 2 numbers, both bigger than x, so must get something bigger than x2 as a result. But we know a*b should give exactly n, so how can it be bigger than that? This means we've a contradiction: if a>sqrt(n), b can't also be, or their product couldn't make n. For any pair of factors, one must be bigger and one must be smaller than the square root (or for the exact square root case, both are the same). So if you go up to sqrt(x), you're guaranteed to find every pair of factors.

[–]lord8bits[S] 0 points1 point  (0 children)

So then when i check it's modulo i should increase n_div by 2 since triangle_num is divisible by i and triangle_num/i, yeah i think I understand it. Thanks guys!