"If the facts don't fit the theory, get new facts" --Albert Einstein
I don't think he has asked twice.Joywish Man wrote:I think you have posted this same query in intermediate section also!
"If the facts don't fit the theory, get new facts" --Albert Einstein
"If the facts don't fit the theory, get new facts" --Albert Einstein
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
"If the facts don't fit the theory, get new facts" --Albert Einstein
Hunter McMillen wrote:Nice, I changed the upper bound to Math.sqrt(n) then incremented by two to account for n/1 and n/n;
now it looks like this:
This change got me the correct answer in a much faster amount of time. If i can ask though why do you only need to go from 1 to Math.sqrt(n). Is that because you assume there are no more factors of n after Math.sqrt(n)??
Thanks,
Hunter M.
Steve
"If the facts don't fit the theory, get new facts" --Albert Einstein
If the number is a perfect square, eg 36 as stated previously, you need to catch the 6 in the middle. A < will miss that out.Hunter McMillen wrote:
"If the facts don't fit the theory, get new facts" --Albert Einstein
"If the facts don't fit the theory, get new facts" --Albert Einstein
Campbell Ritchie wrote:You're welcome Following Garrett's suggestion about square root, I got it to complete in about 2 seconds.
Steve