Skip to content

Instantly share code, notes, and snippets.

@anarcher

anarcher/Euler02 Secret

Last active December 16, 2015 11:19
Show Gist options
  • Save anarcher/04168f40ac6ccdfb5d6b to your computer and use it in GitHub Desktop.
Save anarcher/04168f40ac6ccdfb5d6b to your computer and use it in GitHub Desktop.
Euler02
package main
import (
"fmt"
)
func main() {
limit := 4000000
sum := 0
for a,b := 1,2 ; b < limit; {
if b % 2 == 0 {
sum = sum + b
}
a,b = b,b+a
}
fmt.Printf("%v\n",sum)
}
def fb(l:Int,t:Int=0,e:Int=2,s:Int=1) : Int = {
if(e > l) return t
if(e % 2 == 0) fb(l,t+e,e+s,e)
else fb(l,t,e+s,e)
}
println(fb(4000000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment