Conditions | 3 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | 3 | import {MAX_LOOPS} from './config' |
|
49 | |||
50 | /** |
||
51 | * Traverse the tree towards the float, yielding the values of the continued fraction, ie. the length of runs left/right. |
||
52 | */ |
||
53 | 3 | export function *continuedFraction(n: number): Generator<number> { |
|
54 | 5 | let last = true |
|
55 | 5 | let run = 0 |
|
56 | 5 | for (const direction of pathToValue(n)) { |
|
57 | 515 | if (direction === last) { |
|
58 | 421 | run++ |
|
59 | } |
||
60 | else { |
||
61 | 94 | yield run |
|
62 | 94 | run = 1 |
|
63 | 94 | last = direction |
|
64 | } |
||
67 |