People need help with an activity:
Consider three number vectors. Write a program to print out the largest Twins in each vector.
Which are the largest prime numbers of twins considering all the elements. (In all vectors)
NOTE: The solution should optimize the runtime. You are not allowed to use the Collections API.
I'm having a hard time in the Threads implementation part where I have to allocate the optimization to the runtime.
public class NumeroPrimoGemeo {
public List<Integer> retornaNumeroGemeos(Integer comeco, Integer fim){
int i = comeco;
while(i <= fim){
if(verificaNumeroPrimo(i)){
int x = i + 2;
if(verificaNumeroPrimo(x)){
List<Integer> integers = new ArrayList<>();
integers.add(i);
integers.add(x);
return integers;
}
}
i++;
} throw new RuntimeException("Não há nenhum numero primo gemeos ");
}
Can someone make a code and explain me with comments?