Skip to content

Instantly share code, notes, and snippets.

View danielrangelmoreira's full-sized avatar

Daniel Rangel danielrangelmoreira

View GitHub Profile
@danielrangelmoreira
danielrangelmoreira / fib.go
Last active November 17, 2020 12:41
Fastest, coolest, fibonacci algorithm golang with dynamic programming
package main
import (
"fmt"
"math/big"
)
func fib(n int) *big.Int {
fn := make([]*big.Int, n+1)
for i := 0; i <= n; i++ {
@danielrangelmoreira
danielrangelmoreira / insert.go
Created May 18, 2017 13:05
Insert items in a sorted slice/array (golang)
package main
import "sort"
import "fmt"
func main() {
data := []int{20, 21, 22, 24, 25, 26, 28, 29, 30, 31, 32}
var items = []int{23, 27}
for _, x := range items {
@danielrangelmoreira
danielrangelmoreira / heapPermutation.go
Last active April 30, 2017 20:35
Non recursive Heap (1963) algorithm
package main
import "fmt"
func generate(n int, a []int64) {
var c = make([]int, n)
fmt.Println(a)
i := 0
for i < n {
if c[i] < i {
@danielrangelmoreira
danielrangelmoreira / totients.go
Created April 23, 2017 16:25 — forked from iandioch/totients.go
Golang implementation of Euler's totient/phi function
/*
* Go implementation of Euler's product formula to find for the totient function (aka. phi function)
* https://en.wikipedia.org/wiki/Euler's_totient_function#Euler.27s_product_formula
*/
package main
import (
"fmt"
)
@danielrangelmoreira
danielrangelmoreira / newtonsqrt.go
Created March 19, 2017 19:37
Naive way of obtaining square roots with newton's approximation method
package main
import (
"fmt"
//"math"
)
func main() {
const (
x0 = 54777

Keybase proof

I hereby claim:

  • I am danielrangelmoreira on github.
  • I am danielrangel (https://keybase.io/danielrangel) on keybase.
  • I have a public key ASBXWaRcYRFi-X9IvsNKjfVxst5AUGHUY_uZGoeWrdpH2Ao

To claim this, I am signing this object: