aboutsummaryrefslogtreecommitdiff
path: root/challenge-243/deadmarshal/d/ch2.d
blob: 13c2f017c393bfde9d67a3f2aea71e195a7b6717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import std.stdio:writeln;

ulong floor_sum(ref int[] arr)
{
  ulong sum = 0;
  for(ulong i = 0; i < arr.length; ++i)
    for(ulong j = 0; j < arr.length; ++j)
      sum += int(arr[i] / arr[j]);
  return sum;
}

void main()
{
  int[] arr1 = [2,5,9];
  int[] arr2 = [7,7,7,7,7,7,7];
  writeln(floor_sum(arr1));
  writeln(floor_sum(arr2));
}