Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Rangel danielrangelmoreira

View GitHub Profile
View keybase.md

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:

@danielrangelmoreira
danielrangelmoreira / totients.go
Created Apr 23, 2017 — forked from iandioch/totients.go
Golang implementation of Euler's totient/phi function
View totients.go
/*
* 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 / heapPermutation.go
Last active Apr 30, 2017
Non recursive Heap (1963) algorithm
View heapPermutation.go
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 / insert.go
Created May 18, 2017
Insert items in a sorted slice/array (golang)
View insert.go
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 / fib.go
Last active Nov 17, 2020
Fastest, coolest, fibonacci algorithm golang with dynamic programming
View fib.go
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 / newtonsqrt.go
Created Mar 19, 2017
Naive way of obtaining square roots with newton's approximation method
View newtonsqrt.go
package main
import (
"fmt"
//"math"
)
func main() {
const (
x0 = 54777