# Count Consecutive Primes in Java

/** * This method calculates the number of consecutive prime numbers that * result from a quadratic equation. * Assume the quadratic equation is in this form: x^2 + a*x + b * Pass the method the a and b coefficients. * * @param a Coefficient of the middle term of the quadratric * @param b Coefficient of the rightmost term of the quadratic * @return The number of consecutive primes generated by the * quadratic, starting with x = 0. */ private static int countConsecutivePrimes(int a, int b) { int count, value = 0, num = 0; count = 0; while (true) { value = num * num + a * num + b; if (Utils.isPrime(value) == true) { count++; } else { break; } num++; } return count; }

- The Contest Center - Mathematical Puzzles

Puzzles involving prime numbers and factors. - Mersenne Primes: History, Theorems and Lists

The definitive pages on the Mersenne primes and the related mathematics!

## More by this Author

- 5
A useful text editor is an essential component of any personal computer. Every day we need to make notes, compose documents, and record vital pieces of information. We depend on our text editor. Microsoft provided...

- 12
Data Hiding is an aspect of Object Oriented Programming (OOP) that allows developers to protect private data and hide implementation details. In this tutorial we examine basic data hiding techniques in Java.

- 86
Ever been to a NASCAR race? I thought not. Here are my top 10 reasons why NASCAR racing doesn't rock.

## Comments

No comments yet.