Ad
  • Custom User Avatar

    I agree with everything above, but there is another problem.

    -prefer performance over making your life easy or making your code shorter

    A stream in this case is much slower than prime factorization followed by permutation. During my tests, the stream solution (even using n/2) takes about 80 milliseconds for 1-250. Prime factorization and permutation takes 2. When you bump the range up to 1-24000 it's 4100ms for streams and 150ms for prime factorization and permutation. Don't use a tool when it's inappropriate to do so.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution