// 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.
// JavaScript var = function (array, minValue, maxValue){ var isInLimit = function (value) { return value >= minValue && value <= maxValue; } var = function (array, func) { var results = []; array.forEach(function(element, index, array) { if (!!func(element)) { results.push(index); } }); return results; } return (array, isInLimit); }
// That's an example of using the function ([1, 5, 2, 3, 4], 1, 3);
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.
var = function (array, minValue, maxValue){
var isInLimit = function (value) {
return value >= minValue && value <= maxValue;
}
var = function (array, func) {
var results = [];
array.forEach(function(element, index, array) {
if (!!func(element)) {
results.push(index);
}
});
return results;
}
return (array, isInLimit);
}
// That's an example of using the function
([1, 5, 2, 3, 4], 1, 3);