Need Help With this problem
A twin prime is a prime number that differs from another prime number by exactly 2. For
example, 3 and 5 are twin primes, since 3 and 5 are each prime and differ by 2
(likewise, 5 and 7 are also twin primes).
Complete the twins() method, which takes an integer argument n and prints all the
sets of twin primes that are less than n, one pair per line. The method does not return
any value. For example, twins(15) would print
Use the sieve() method from Part 1 to generate the initial list of prime numbers.
This is what I have:
public static void twins (int max)
ArrayList<Integer> twins= sieve(max);
int index = 0;
for (index = 0; twins.size() - 1 > index; index++)
if (twins.get(index+1) - twins.get(index) == 2)
Re: Need Help With this problem
Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.
Please post your code correctly. What do you need help with? Please ask a specific question so that we know where to start and that you want something other than someone to just complete your code for you.