An N * M matrix is given. Find the arithmetic mean of the prime numbers of a matrix.

program zz1;
const n = 8;
b = 7; // set the number of elements in the array
var i, j, k, s: integer; // set variables of integer type
m: array [1..n, 1..b] of integer;
function Prost (a: longint): boolean;
var k: longint;
f: boolean;
begin
if a <2 then f: = false
else
begin
f: = true;
k: = 2;
while (k * k <= a) and f do // while the counter is less than the root of the number and there are no divisors
if a mod k = 0 then f: = false // if divisor, then not prime
else k: = k + 1;
end;
Prost: = f;
end;

begin
for i: = 1 to n do
for j: = 1 to b do // get numbers and write them into an array
m [i, j]: = random (101);
for i: = 1 to n do // display the resulting array on the screen
begin
for j: = 1 to b do
write (m [i, j]: 4);
writeln;
end;
for i: = 1 to n do
for j: = 1 to b do
if Prost (m [i, j]) then begin s: = s + m [i, j]; k: = k + 1; end;
write (‘the arithmetic mean of simple array elements =’, s / k); // display the answer
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.