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

module example_divisors;

var
	n, i, nof : integer;

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