summaryrefslogtreecommitdiff
path: root/tests/exec/fact_loop.cpp
blob: da13f82b8f74b46845d1d672a42740764460af2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

int fact_loop(int n) {
  int r = 1;
  while (n > 1) r = r * n--;
  return r;
}

int main() {
  std::cout << fact_loop(5) << "\n";
}