fork(1) download
  1. <?php
  2. for ($x = 2; $x <= 21; $x++) {
  3. $n = floor((sqrt(1 + 8 * ($x - 1)) - 1) / 2);
  4. $lower = $x - $n;
  5. $upper = $x - 1;
  6. printf("%d: %d - %d\n", $x, $lower, $upper);
  7. }
  8. ?>
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
2: 1 - 1
3: 2 - 2
4: 2 - 3
5: 3 - 4
6: 4 - 5
7: 4 - 6
8: 5 - 7
9: 6 - 8
10: 7 - 9
11: 7 - 10
12: 8 - 11
13: 9 - 12
14: 10 - 13
15: 11 - 14
16: 11 - 15
17: 12 - 16
18: 13 - 17
19: 14 - 18
20: 15 - 19
21: 16 - 20