Struggling with a Simple Registration Puzzle—Am I Overthinking It?

August 9, 2026 1 answer
Asked by MellowPine47
I've been stuck on the registration puzzle for about two hours and I'm starting to wonder whether I'm missing something obvious. I have a computer science degree and have worked as a web developer for five years, but I can't seem to solve what appears to be a very basic programming problem. The task asks: among the first 393,000 square numbers, what is the sum of all the odd squares? Any advice on how to approach it without overcomplicating things?

Answers

CobaltFox_82
Take a step back and start with the simplest possible approach. The first 393,000 square numbers are 1², 2², 3², and so on through 393,000². Only odd indices produce odd squares, so you need to add the squares of the first 196,500 odd numbers. You can brute-force that in a loop, which is completely reasonable here. If you want a direct formula, the sum of the first m odd squares is m(4m² − 1)/3, with m = 196,500. Test your code with a few small cases first so you can verify the pattern before plugging in the full value.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions