Browse Source

style changes

master
Evan Hemsley 2 years ago
parent
commit
6a0060567f
  1. 2
      v/euler/euler.v
  2. 17
      v/euler001.v
  3. 6
      v/euler002.v

2
v/euler/euler.v

@ -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
}

17
v/euler001.v

@ -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))
}

6
v/euler002.v

@ -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))
}
Loading…
Cancel
Save