Hacker News new | ask | show | jobs
by margalabargala 4 days ago
> Before anyone asks, can I break cable crypto and get free cable? not unless you can factor large primes

Factoring large primes is easy! I can do it in my head.

Give me any arbitrarily large prime number, and I can immediately tell you all its factors.

1 comments

I also possess this ability! I can do it in O(log n)
I can do it in O(1). Give me a large prime number, and I'll tell you both of its factors immediately.
It's O(log n), unless the answer is accepted in a compressed format, with the query assumed to be known. You need to either tell the log n bits explicitly to the one who asks, or refer to them.
You seem to be missing my cheeky "both". Prime numbers by definition only have two factors. If you give me a prime number, no matter how large it is, I'll tell you the same number back and 1, immediately, and I'll be right!

Or maybe we have very different definition of the runtime of returning an integer? I don't think it makes sense to say that returning an N bit number requires O(log n).

And this is exactly the source of the disagreement. For an arbitrary large integer not fitting in a single register, returning it in fresh storage must copy all its bytes. That's why it cannot be O(1).
How are you passing my function the integer in the first place? Presumably if it's this large, you're using some sort of reference, so I can just give it back to you.