View Fibonacci.rb
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
def fibonacci(n) | |
return n if ( 0..1 ).include? n | |
(fibonacci(n - 1) + fibonacci( n - 2 )) | |
end | |
start = Time.now | |
fibonacci(22) | |
p Time.now - start |
View Fibonacci.py
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
import time | |
def Fibonacci(n): | |
if n<2: | |
return 1 | |
else: | |
return Fibonacci(n-1)+Fibonacci(n-2) | |
start = time.time() | |
Fibonacci(22) | |
print(time.time() - start) |
View Fibonacci.php
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
<?php | |
function fibonacci($n){ | |
$start = microtime(true); | |
if ($n < 2){ | |
$f = 1; | |
}else{ | |
$f = fibonacci($n - 2) + fibonacci($n - 1); | |
} | |
return microtime(true) - $start; | |
} |
View bubble.php
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
<?php | |
function bubble_sort($array) | |
{ | |
$start = microtime(true); | |
do | |
{ | |
$sw = false; | |
for($i = 0, $size = count($array) - 1; $i < $size; $i++) | |
{ | |
if( $array[$i] > $array[$i + 1] ) |