![]() On the other hand, this won't halve running time because odd numbers like 91 and and 2209 might require more effort to be ruled out as not prime. Your program should simply skip even numbers, because, aside from −2 and 2, they're all composite. Checking if the digit is 0, 2 or 4 or 6 or 8 then skipping the numberĮlse calculating the square root of the number.The last digit? In what base? Base 10? I think this might be your problem. Calculating the last digit of the number to be checked.You already knew, and working on this program would have helped confirm this. I am convinced that including it was an honest mistake. ![]() Hard-coding 3 might save, at most, a millisecond.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |