Yes, I found it a bit odd too that the OP claims interest in math yet seems to have problems understanding computational complexity. Although, mathematics is a very broad subject, maybe his focus was on something else.
I loop twice, so complexity is O(2N).
Actually, it's still O(N).
Why the rejetions? Has any company told you what exactly were the reasons for rejection? Ask for a reply from the interviewers and the specific questions. Don't get those questions wrong again.
How about a link to the contributions? Perhaps you can get some better feedback from people looking at those. Why the blundering? It's not a memorization exercise, it's an exercise in counting and math: I think most good interviewers will be ecstatic if you can reason your algorithm out loud, even if you're a little off. It's the reasoning and thinking that matters more.I'd also recommend studying for interviews seriously. Cracking the code interview, http://www.amazon.com/Cracking-Coding-Interview-Programming-..., it helps quite a bit.