Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[C++] Checking primality
#2
Yes this definitely works, I see you use modulus to calculate the remainder of 0 for your divisibility, and anything not divisible by 2 won't be divisible by 4,6,8, etc... So checking for divisibility by 2 from the start, and then counting every odd number for divisibility from that point forward makes lots of sense, nice loop Smile
Reply


Messages In This Thread
[C++] Checking primality - by Nightly - 02-13-2012, 11:51 PM
RE: [C++] Checking primality - by AceInfinity - 02-14-2012, 07:00 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)