// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
// This provides interface PrimeTable that determines whether a number is a
// prime and determines a next prime number. This interface is used
// in Google Test samples demonstrating use of parameterized tests.
bool IsPrime(int n) const override {
if (n <= 1) return false;
- for (int i = 2; i*i <= n; i++) {
+ for (int i = 2; i * i <= n; i++) {
// n is divisible by an integer other than 1 and itself.
if ((n % i) == 0) return false;
}
// Checks every candidate for prime number (we know that 2 is the only even
// prime).
- for (int i = 2; i*i <= max; i += i%2+1) {
+ for (int i = 2; i * i <= max; i += i % 2 + 1) {
if (!is_prime_[i]) continue;
// Marks all multiples of i (except i itself) as non-prime.
// We are starting here from i-th multiplier, because all smaller
// complex numbers were already marked.
- for (int j = i*i; j <= max; j += i) {
+ for (int j = i * i; j <= max; j += i) {
is_prime_[j] = false;
}
}