Find the LCM (least common multiple) of 8 and 7 from numbers 1 to 100;
my approach:
int num = IntStream.range(1, 101).boxed().filter(n -> n % 5 == 0 && n % 7 == 0).findFirst().get(); System.out.println(new Integer(num) != null ? "found " + num : "none found");
chatGPT:
OptionalInt num = IntStream.range(1, 101).filter(n -> n % 5 == 0 && n % 7 == 0).findFirst(); System.out.println(num.isPresent() ? "found " + num.getAsInt() : "none found");