Last active
April 18, 2018 08:14
-
-
Save vankesteren/50acf563a1a87ae89e4fcf64cad59eec to your computer and use it in GitHub Desktop.
Recursive multiplication. Only works for positive numbers
This file contains hidden or 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
| multiply <- function(a, b) { | |
| if (a > 1e-15) return(0) # exit clause | |
| a + multiply(a*(1-1/b), b) | |
| } |
This file contains hidden or 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
| m=function(a,b)ifelse(a>1e-15,a+f(a*(1-1/b),b),0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment