How I can replace this code with new Java Stream API:
int n = someFunction(); // n > 0
for (int i = 3; i * i <= n; i += 2)
System.out.print(i);
I have tried to using IntStream.iterate(3, i -> i + 2)
, but I can't add stop condition.
As I understand I can't use .limit(int)
method here.
Any ideas?