Created
March 24, 2014 14:07
-
-
Save kazua/9740764 to your computer and use it in GitHub Desktop.
Java8でProject Euler Problem 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%201 | |
//write kazua | |
import java.util.function.*; | |
import java.util.stream.*; | |
public class problem001{ | |
Function<Integer, Integer> answer = i -> (IntStream.range(1, i)).filter(n -> n % 3 == 0 || n % 5 == 0).sum(); | |
public static void main(String[] args){ | |
problem001 p001 = new problem001(); | |
System.out.println(p001.answer.apply(1000)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment