style changes

master
Evan Hemsley 2020-01-08 03:23:40 -08:00
parent 920853c7bd
commit 6a0060567f
3 changed files with 8 additions and 17 deletions

View File

@ -9,6 +9,8 @@ pub fn range(start int, end int) []int {
return result
}
pub fn add(i int, j int) int { return i + j }
pub fn even(n int) bool {
return n % 2 == 0
}

View File

@ -1,17 +1,10 @@
import euler
fn multiples_of_three_and_five_below(n int) []int {
mut nums := []int
for i := 3; i < n; i++ {
if i % 3 == 0 || i % 5 == 0 {
nums << i
}
}
return nums
nums := euler.range(3, n-1)
return nums.filter(it % 3 == 0 || it % 5 == 0)
}
fn main() {
mut result := 0
for n in multiples_of_three_and_five_below(1000) {
result += n
}
println(result)
println(multiples_of_three_and_five_below(1000).reduce(euler.add, 0))
}

View File

@ -14,9 +14,5 @@ fn even_fibonacci_up_to(n int) []int {
}
fn main() {
mut result := 0
for n in even_fibonacci_up_to(4000000) {
result += n
}
println(result)
println(even_fibonacci_up_to(4000000).reduce(euler.add, 0))
}