Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 759 Bytes

README.md

File metadata and controls

22 lines (15 loc) · 759 Bytes

expr2cf

Converts a simple mathematical expression to a continued fraction sequence

Requirements

Usage/examples

  • to evaluate an expression: echo "2 + 0.8031975" | expr2cf => [2, 1, 4, 12, 3, 4, 2, 1, 1, 1, 1, 2, 1, 1, 5]

  • to get an approximated fraction of pi (from 18 decimal digits): echo "scale=18; 4*a(1)" | BC_LINE_LENGTH=0 bc -l | expr2cf | cf2expr => 14308127635/4554418479

  • to get an approximated fraction of the golden ratio (Phi): echo "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]" | cf2expr => 6765/4181