Skip to content

Instantly share code, notes, and snippets.

@anarcher

anarcher/Euler01 Secret

Last active December 16, 2015 11:19
Show Gist options
  • Save anarcher/066fb9cfb7dd19af493b to your computer and use it in GitHub Desktop.
Save anarcher/066fb9cfb7dd19af493b to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func main() {
sum := 0
for i := 0 ; i < 1000 ; i ++ {
if i % 3 == 0 || i % 5 == 0 {
sum = sum + i
}
}
fmt.Printf("sum:%v\n",sum)
}
scala> (0 /: (1 until 1000))( (x,y) => if ( y %3 == 0 || y % 5 == 0 ) x+y else x )
res43: Int = 233168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment