Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 19 lines (15 sloc) 0.462 kb
02e626a @colomon Start first continued fraction experiments.
authored
1 use Test;
2
3 plan 4;
4
5 sub make-continued-fraction (Real $x is copy) {
6 gather loop {
7 my $a = $x.floor;
8 take $a;
9 $x = $x - $a;
10 last if $x == 0;
11 $x = 1 / $x;
12 }
13 }
14
15 is make-continued-fraction(3), [3], "Sanity test";
16 is make-continued-fraction(-42), [-42], "Sanity test";
17 is make-continued-fraction(3.245), [3, 4, 12, 4], "Wikipedia example works";
18 is make-continued-fraction(-4.2), [-5, 1, 4], "Wikipedia example works";
Something went wrong with that request. Please try again.