The question I was given is:
Find and print (one per line) those values of a that are of the form 3x+ 1 for some x. Each such value should be printed only once, in the position it first appears.
I have tried many variations of modulo to try and get the correct numbers but I can't seem to wrap my head around the problem.
This is the code I was given to start:
import java.util.*;
import java.util.stream.*;
class Example {
public static void main(String argv[]) {
int a[] =
Arrays.stream(argv)
.mapToInt(s -> Integer.parseInt(s))
.toArray();
}
// fill in here with expression starting Arrays.stream(a)
}
Thanks for any help.