Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
@thinkphp
thinkphp / monte_carlo_PI.c
Last active June 10, 2025 15:16
C program to compute PI using a Monte Carlo Method.
/**
*
* Author : Adrian Statescu mergesortv@gmail.com http://adrianstatescu.com
*
* Description: C Program to compute PI using a Monte Carlo Method.
*
* MIT License
*
*/
@thinkphp
thinkphp / euclid.go
Last active March 3, 2017 15:49
Euclid's algorithm is an efficient method for computing the greatest common divisor of two numbers, I mean the largest number that divides both of them without leaving a remainder.
/**
*
* Adrian Statescu (http://adrianstatescu.com)
*
* Euclid's algorithm is an efficient method for computing the greatest common divisor of two numbers, I mean the largest number that divides both of them without leaving a remainder.
*
* License MIT
*
*/
@thinkphp
thinkphp / bubblesort.go
Last active March 6, 2017 06:00
bubblesort in Golang
/**
*
* Author : Adrian Statescu mergesortv@gmail.com http://adrianstatescu.com
*
* Description: BubbleSort is a simple sorting algorithm that repeatedly steps through the elements
* in an array to be sorted, compares each pair of adjiacent elements and swap thems
* if they are in the wrong order.
* The pass through the list is repeated until no more changes swaps are needed.
*
* Complexity : Worst-case O(n^2)
/**
*
* Author : Adrian Statescu mergesortv@gmail.com http://adrianstatescu.com
*
* Description: BubbleSort is a simple sorting algorithm that repeatedly steps through the elements
* in an array to be sorted, compares each pair of adjiacent elements and swap thems
* if they are in the wrong order.
* The pass through the list is repeated until no more changes swaps are needed.
*
* Complexity : Worst-case O(n^2)
/**
*
* Author : Adrian Statescu mergesortv@gmail.com http://adrianstatescu.com
*
* Description: BubbleSort is a simple sorting algorithm that repeatedly steps through the elements
* in an array to be sorted, compares each pair of adjiacent elements and swap thems
* if they are in the wrong order.
* The pass through the list is repeated until no more changes swaps are needed.
*
* Complexity : Worst-case O(n^2)
@thinkphp
thinkphp / leibniz_PI.go
Created March 7, 2017 19:08
Approximation of PI using Leibniz method in golang.
/**
* Adrian Statescu <mergesortv@gmail.com> (http://adrianstatescu.com)
*
* Approximation of PI using Leibniz method.
* 1-1/3+1/5-1/7
*
* Compile and Run -> go run leibniz_pi.go
*
* License: MIT
*/
@thinkphp
thinkphp / leibniz.rb
Created March 8, 2017 19:53
PI Approximation in Ruby language.
# Adrian Statescu <mergesortv@gmail.com> http://adrianstatescu.com
# Computes PI using Leibniz method
# MIT License
def PI ep
anEPS = ep
term1 = 1.0
term2 = 1.0 - 1.0/3
@thinkphp
thinkphp / quadratic.c
Last active March 9, 2017 15:14
Quadratic Equation Solver in C language.
/**
* Author: Adrian Statescu <mergesortv@gmail.com> http://adrianstatescu.com
* Description: Quadratic Equation Solver in ANSI C Language
* MIT License
*/
#include <stdio.h>
#define FIN "quadratic.in"
#define FOUT "quadratic.out"
#define MAXEQ 100
@thinkphp
thinkphp / quadratic-equation-solver.rb
Last active March 9, 2017 16:18
Quadratic Equation solver in Ruby Language.
#
# Adrian Statescu <mergesortv@gmail.com> http://adrianstatescu.com
# Quadratic Equation Solver
# MIT License
#
require "cmath"
def quadratic
arr = []
@thinkphp
thinkphp / e.rb
Created March 9, 2017 17:25
Euler's Number in Ruby language.
#
# Adrian Statescu <mergesortv@gmail.com> http://adrianstatescu.com
# Number's Euler e = 2.7182...
# MIT License
#
def fact n
if n == 0
1
else