Given three consecutive even numbers. Prove mathematically that atleast one of them is divisible by 6.

Examples:

Input : {2, 4, 6} Output : 6 is divisible by 6 Input : {8, 10, 12} Output : 12 is divisible by 6

**Question Source :** Amazon interview experience | Set 383 (On-Campus for Internship)

If you see the any three consecutive numbers, you can figure out atleast one of them is divisible by 6.

We can use mathematical induction for proving it mathematically.

For a number to be divisible by 6, it should be divisible by 2 and 3.

Since all are even numbers, the number will be divisible by 2.

For checking divisibility of number by 3,

Consider below proof :

Consider 3 consecutive even numbers : P(i) = {i, i+2, i+4} (i is divisible by 2) If one of these three numbers is divisible by 3, then their multiplication must be divisible by 3 Base case : i = 2 {2, 4, 6} Multiplication = (2*4*6) = 3*(2*4*2) So, it is divisible by 3 For i = n P(n) = {n, n+2, n+4} multiplication = (n*(n+2)*(n+4)) since P(n) is divisible by 3 means P(n) = n*(n+2)*(n+4) = 3k for positive number k If the statement holds for i = n, it should hold for next consecutive even number i.e. i = n + 2 P(n+2) = (n+2)*(n+4)*(n+6) It can be written as P(n+2) = n*(n+2)*(n+4) + 6*(n+2)*(n+4) P(n+2) = P(n) + 6*x where x = (n+2)*(n+4) So, P(n+2) = 3*k + 6*x both the summation elements of P(n+2) are divisible by 3, so P(n+2) is divisible by 3 Hence, there is atleast one number among three even consecutive numbers which is divisible by 6.

This article is contributed by **Mandeep Singh**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- NFA to accept strings that has atleast one character occurring in a multiple of 3
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Smallest n digit number divisible by given three numbers
- Largest N digit number divisible by given three numbers
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Check if a number can be written as sum of three consecutive integers
- Count of elements which are second smallest among three consecutive elements
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3
- Find the integer points (x, y) with Manhattan distance atleast N
- Minimum window size containing atleast P primes in every window of given range
- Number of Groups of Sizes Two Or Three Divisible By 3
- Subsequences of size three in an array whose sum is divisible by m
- Average of even numbers till a given even number
- Generate a Binary String without any consecutive 0's and at most K consecutive 1's
- Count prime numbers that can be expressed as sum of consecutive prime numbers
- Generate an alternate odd-even sequence having sum of all consecutive pairs as a perfect square
- Find permutation of n which is divisible by 3 but not divisible by 6
- Count the number of pairs (i, j) such that either arr[i] is divisible by arr[j] or arr[j] is divisible by arr[i]
- Count numbers which are divisible by all the numbers from 2 to 10