Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> If you choose n to be a non-infinite number, then the complexity of the program is O(1) If you choose n to be infinite then the complexity is O(inf)

I'm not sure I understand this, or you've understood me. The number n starts out at 1, and the next time around is 2, then 3, and so forth.



My explanation is not to be understood easily( that doesn't mean it is very clear( or good ) ). Your best bet here would probably be to study big-o notation(+math, function limits) and think of the solution for yourself( there definitely is one ), as it can become quickly confusing as to what are you measuring really.


I understand big-O notation just fine. I asked a specific question about your post, and nothing that indicated I misunderstood the principle in general. You spoke of "choosing n" to be either infinite or non-infinite, which doesn't make sense to me given the algorithm I proposed.


I didn't explain that( was edited ), of course you start at with n at 1,2,3... and so forth. But you can decide when to stop, and so I made two cases.

Anyway; you gave me a good exercise to practice on. Thanks.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: