Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / gist:1529713
Created December 28, 2011 21:00
Ln in Python
'''
x
f(x) = e - a
if f(0)*f(a) < 0 then exists the solution (0,a]
'''
import math
import sys
def loge(n,li,ls):
if math.fabs(li-ls) <= 0.000001:
@thinkphp
thinkphp / gist:1543590
Created December 31, 2011 10:07
Computes square root in Python SQRT
'''
Computes SQuare RooT in Python SQRT
s = (s+nr/s)1/2
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
'''
@thinkphp
thinkphp / gist:1641985
Created January 19, 2012 19:29
Insertion Sort in JavaScript
/*
Insertion Sort in JavaScript
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
*/
function insertionSort(arr) {
var n = arr.length-1,
@thinkphp
thinkphp / gist:1642090
Created January 19, 2012 19:38
Insertion Sort in PHP
/**
Insertion Sort in PHP
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
*/
function insertionSort($arr){
$n = count($arr);
@thinkphp
thinkphp / gist:1642099
Created January 19, 2012 19:40
Insertion Sort in Python
'''
Insertion Sort
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
'''
def insertionSort(arr):
@thinkphp
thinkphp / gist:1642162
Created January 19, 2012 19:51
Insertion Sort pseudocode
/*
Pseudocode of the complete algorithm
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
*/
INSERTION-SORT(V)
@thinkphp
thinkphp / gist:1862867
Created February 19, 2012 09:51
sin(x) in Python
'''
sin(x) = x-x^3/3!+x^5/5!-x^7/7!+..-
'''
import math
def fact(n):
if n==0:
return 1
else:
return n*fact(n-1)
@thinkphp
thinkphp / gist:1862871
Created February 19, 2012 09:52
cos(x) in Python
'''
cos(x) = 1-x^2/2!+x^4/4!-x^6/6!+..-
'''
import math
def fact(n):
if n==0:
return 1
else:
return n*fact(n-1)
@thinkphp
thinkphp / gist:1862877
Created February 19, 2012 09:54
sin(x) in PHP
/*
* Twitter @thinkphp
*
* Approximate the function sin with series Taylor!
* sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ....(-1)^n+1*x^(2n+1)/(2n+1)!;
*
*/
function fact($n) {
@thinkphp
thinkphp / gist:1862882
Created February 19, 2012 09:54
cos(x) in PHP
<?php
/*
* @thinkphp
*
* Approximate the function sin with series Taylor!
* cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ....(-1)^n*x^(2n)/(2n)!;
*
*/
function fact($n) {