Multiple of Previous Two

Write a program that reads a sequence of positive integers and reports
the first one that is a multiple of both two previous numbers in the
sequence, together with the corresponding quotients.

Input

A sequence of positive integers i₀, i₁, i₂, ... finished by the value -1
that marks the end and does not count as a member of the sequence. There
is no constraint (neither upper nor lower) on the length of the
sequence.

Output

The first value i_(n) in the sequence that is a multiple of both
previous ones (that is, i_(n) is a multiple of i_(n − 1) and of
i_(n − 2)) together with the corresponding quotients (namely,
i_(n)/i_(n − 1) and i_(n)/i_(n − 2)). In case no element of the sequence
fulfills this condition, the output should be 0 (the integer zero).

Observation

The usage of “break” is hereby explicitly forbidden.

Problem information

Author: José Luis Balcázar

Generation: 2026-01-25T14:28:42.026Z

© Jutge.org, 2006–2026.
https://jutge.org
