View sin.ruby
#
# Adrian Statescu <mergesortv@gmail.com>
# Computes SIN using Taylor Series
#
# sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ...
#
#
def fact n
View gdc.hs
gdc :: Int -> Int -> Int
gdc x y | x == y = x
| x > y = gdc (x - y) y
| x < y = gdc x (y - x)
View addmult.hs
add' :: Int -> Int -> Int
add' x y = x + y
mult :: Int -> Int -> Int -> Int
mult x y z = x * y * z
View ln.ruby
def f x,a
Math.exp(x)-a
end
def ln a
lo, hi = 0, a
anEPS = 0.0001
while (lo-hi).abs >= anEPS
m = ((lo+hi)/2.0).to_f
if f(m,a) < 0
View ln.go
/*
* Adrian Statescu <mergesortv@gmail.com
* Natural Logarithm in Golang.
* ln(1) = 0
*/
package main
import ("fmt"
"os"
"strconv"
View ln.c
double computesLN2(double n, double lo, double hi) {
double a = lo, b = hi, m;
while( fabs(a - b) > EPS ) {
m = (a + b) / 2.0;
if( (f( m, n) ) < 0) a = m;
View sqrt.rb
#
# Adrian Statescu <mergesortv@gmail.com>
# This Method Computes SQuare RooT in Ruby.
# MIT License
#
def sqrt(n)
an = n / 2.0
View combination.go
/**
*
* Adrian Statescu (http://adrianstatescu.com)
*
* Comb using Pascal's Triangle
*
* License MIT
*
*/
package main
View triangle-pascal.go
/**
*
* Adrian Statescu (http://adrianstatescu.com)
*
* Pascal's Triangle
*
* License MIT
*
*/
package main
View sqrt.go
/**
*
* Adrian Statescu (http://adrianstatescu.com)
*
* Computes SQuar RooT (SQRT) using recurrence relations.
*
* anplus1 = ( an + n / an ) / 2
*
* License MIT
*