Created
December 25, 2017 18:48
-
-
Save wmmnola/884da0813bfbb8f4c601e48c27a0b79e to your computer and use it in GitHub Desktop.
Continued Fraction implementation of sqrt(n) for fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float slowsqrt(float n); | |
float nestedSqrt(float n, float level); | |
float slowsqrt(float n){ | |
float s = 1 + ((n-1)/nestedSqrt(n,0)); | |
return s; | |
} | |
float nestedSqrt(float n, float level){ | |
if(level < 30){ | |
return 2 + ((n-1)/nestedSqrt(n, level+1)); | |
} | |
else{ | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment