@@ -0,0 +1,2140 @@
+/*     / %5C____  _    ______   _____ / %5C____   ____  _____%0A *    /  %5C__  %5C/ %5C  / %5C__  %5C /  __//  %5C__  %5C /    %5C/ __  %5C   Javaslang%0A *  _/  // _%5C  %5C  %5C/  / _%5C  %5C%5C_  %5C/  // _%5C  %5C  /%5C  %5C__/  /   Copyright 2014-2015 Daniel Dietrich%0A * /___/ %5C_____/%5C____/%5C_____/____/%5C___%5C_____/_/  %5C_/____/    Licensed under the Apache License, Version 2.0%0A */%0Apackage javaslang.collection.euler;%0A%0Aimport javaslang.Function1;%0Aimport javaslang.Function2;%0Aimport javaslang.collection.Stream;%0Aimport org.junit.Test;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0Apublic class Euler14Test %7B%0A%0A    /**%0A     * %3Cstrong%3EProblem 14: Longest Collatz sequence%3C/strong%3E%0A     * %3Cp%3E%0A     *%0A     * The following iterative sequence is defined for the set of positive integers:%0A     *%0A     *    n %E2%86%92 n/2 (n is even)%0A     *    n %E2%86%92 3n + 1 (n is odd)%0A     *%0A     * Using the rule above and starting with 13, we generate the following sequence:%0A     *%0A     * 13 %E2%86%92 40 %E2%86%92 20 %E2%86%92 10 %E2%86%92 5 %E2%86%92 16 %E2%86%92 8 %E2%86%92 4 %E2%86%92 2 %E2%86%92 1%0A     * It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms.%0A     * Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.%0A     *%0A     * Which starting number, under one million, produces the longest chain?%0A%0A     * NOTE: Once the chain starts the terms are allowed to go above one million.%0A     * %3C/p%3E%0A     * See also %3Ca href=%22https://projecteuler.net/problem=14%22%3Eprojecteuler.net problem 14%3C/a%3E.%0A     */%0A    %0A    @Test%0A    public void shouldSolveProblem14() %7B%0A        assertThat(Stream.from(1L)%0A                .take(1_000_000)%0A                .maxBy(collatzSequenceLength)%0A                .get()).isEqualTo(837799);%0A    %7D%0A%0A    private final static Function2%3CLong, Long, Long%3E collatzRecursive = (len, n) -%3E %7B%0A        if (n == 1) return len + 1;%0A        else if (n %25 2 == 0) %7B%0A            return Euler14Test.collatzRecursive.apply(len + 1, n / 2);%0A        %7D else %7B%0A            return Euler14Test.collatzRecursive.apply(len + 1, (3 * n) + 1);%0A        %7D%0A    %7D;%0A%0A    private final static Function1%3CLong, Long%3E collatzSequenceLength = collatzRecursive.memoized().curried().apply(0L);%0A%7D%0A

Add test for Euler 14