Var ar:array[1..n] of integer; ar2:array[1..n] of integer; i,k:integer;
function prost(a:integer):boolean; var i:integer; b:boolean; begin b:=true; for i:=2 to a div 2 do if a mod i=0 then begin; b:=false; break; end; if a=1 then b:=false; prost:=b; end;
begin; randomize; k:=0; for i:=1 to n do begin; ar[i]:=random(101); write(ar[i]:4); end; writeln; for i:=1 to n do if prost(ar[i]) then begin; inc(k); ar2[k]:=ar[i]; write(ar2[k]:4); end; end.
// F# open System [<EntryPoint>] let main argv = let mutable sum = 0 let mutable i = 0 let array = [19..51] while i < array.Length do let value = array.Item i if 5 % value = 0 then sum <- sum + value i <- i+1 Console.WriteLine sum Console.ReadKey true |> ignore 0
// Pascal (for) var sum : integer; i: integer; begin sum := 0; i := 0; for i:=19 to 51 do begin if i mod 5 = 0 then sum := sum + i; end; writeln(sum); end.
// Pascal var sum : integer; i: integer; begin sum := 0; i := 19; while (i <= 51) do begin if i mod 5 = 0 then sum := sum + i; i := i + 1; end; writeln(sum); end.
n=5;
Var
ar:array[1..n] of integer;
ar2:array[1..n] of integer;
i,k:integer;
function prost(a:integer):boolean;
var i:integer;
b:boolean;
begin
b:=true;
for i:=2 to a div 2 do
if a mod i=0 then
begin;
b:=false;
break;
end;
if a=1 then b:=false;
prost:=b;
end;
begin;
randomize;
k:=0;
for i:=1 to n do
begin;
ar[i]:=random(101);
write(ar[i]:4);
end;
writeln;
for i:=1 to n do
if prost(ar[i]) then
begin;
inc(k);
ar2[k]:=ar[i];
write(ar2[k]:4);
end;
end.
open System
[<EntryPoint>]
let main argv =
let mutable sum = 0
let mutable i = 0
let array = [19..51]
while i < array.Length do
let value = array.Item i
if 5 % value = 0 then
sum <- sum + value
i <- i+1
Console.WriteLine sum
Console.ReadKey true |> ignore
0
// Pascal (for)
var sum : integer;
i: integer;
begin
sum := 0;
i := 0;
for i:=19 to 51 do
begin
if i mod 5 = 0 then
sum := sum + i;
end;
writeln(sum);
end.
// Pascal
var sum : integer;
i: integer;
begin
sum := 0;
i := 19;
while (i <= 51) do
begin
if i mod 5 = 0 then
sum := sum + i;
i := i + 1;
end;
writeln(sum);
end.