answersLogoWhite

0

I make it 684. Would you like a list?

The first time I wrote a program to compare the square root of each number from one hundred thousand to one million, and counted only those that were whole. It was late at night, and by compiling my code this brute force approach cranked out an answer in under 30 seconds. Maybe less, I don't remember.

I started to rewrite the same program just now, as I see there has been more activity on this question, but then I realized what a mental midget I had been. In thinking about code optimization it occurred to me that the square root of one million is one thousand, and so to count the perfect squares all I need to do was subtract the integral value of the square root of one hundred thousand (316) from 1000. Each of those numbers has a perfect square in the given range. 1000-316 = 684.

Had I bothered to produce a list of numbers from the original program I would have immediately realized my foolishness.

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa

Add your answer:

Earn +20 pts
Q: How many perfect squares exist between one hundred thousand and one million?
Write your answer...
Submit
Still have questions?
magnify glass
imp