You are given an array of integers of size N. Check if its elements listed in the same order form a geometric progression

You are given an array of integers of size N. Check if its elements listed in the same order form a geometric progression. If they form, then output the denominator of the progression, if not, then output 0.

program zz1;

const n = 5; // set the number of elements in the array

var i, k, v: integer; // set variables of integer type

m: array [1..n] of integer;

begin

for i: = 1 to n do // get n numbers from the keyboard and write them into an array

read (m [i]);

k: = m [2] div m [1]; // find the denominator

for i: = 1 to n-1 do

if m [i] * k = m [i + 1] then v: = v + 1; // check if each subsequent number, starting from the second,

// obtained from the previous one by multiplying it by the denominator, then we consider it

if v = n -1 then write (‘array elements form a geometric progression, denominator =’, k) else write (0);

end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.