The sequence

Report a typo

You are given a sequence of natural numbers. Find the maximum element divisible by 4. The input is passed to the program as follows:

  1. The first number is the total number of elements in the sequence.
    Use this number as a condition for your loop.

  2. The upcoming numbers are part of the sequence which need to be evaluated.

The numbers in the sequence may or may not be evenly divisible divisible by 4. The program should print a single number: the maximum element of the sequence that is evenly divisible by 4.

Try to solve this problem by using a while-loop.

Note: The first number passed to the program (number of elements in the sequence) isn't a part of the sequence.

Sample Input 1:

8
16
49
91
77
36
12
12
36

Sample Output 1:

36
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// start coding here
}
}
___

Create a free account to access the full topic