summaryrefslogtreecommitdiff
path: root/ecomp-c/tests/example_divisors_array_result.e
blob: 3c380da06f010cd3be11731c7d49149a7bc968f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * compute number of all divisors of a number and
 * store them in an array.
 *
 * 100 has 1,2,4,5,10,20,25,50,100 (9 divisors)
 */

module example_divisors_array_result;

var
	n, i, nof : integer;
	divisor : array 20 of integer;

begin
	n := 100;
	i := 1;
	nof := 0;
	while i <= n do
		if n mod i = 0 do
			divisor[nof] := i;
			nof := nof + 1;
		end;
		i := i + 1;
	end
end