Skip to content

A small collection of tools to work with rational numbers

Notifications You must be signed in to change notification settings

velnias75/expr2cf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A small collection of tools to work with rational numbers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published