From my understanding, this is a single statement in Java:
while((x % p == 0l) && (x > p)) x /= p;
If that is the case, why is this a syntax error:
final AtomicLong subtotal = new AtomicLong(limit);
final long maxPrimeFactor = primeStream.takeWhile(p -> p * p <= limit)
.filter(p -> subtotal.get() % p == 0)
.peek(p -> while((subtotal.get() % p == 0) && (subtotal.get() > p)) subtotal.set(subtotal.get() / p)) // Syntax error here.
.dropWhile(p -> p != subtotal.get())
.findFirst()
.getAsLong();
And this is not a syntax error.
final AtomicLong subtotal = new AtomicLong(limit);
final long maxPrimeFactor = primeStream.takeWhile(p -> p * p <= limit)
.filter(p -> subtotal.get() % p == 0)
.peek(p -> { while((subtotal.get() % p == 0) && (subtotal.get() > p)) subtotal.set(subtotal.get() / p)); } // No syntax error here.
.dropWhile(p -> p != subtotal.get())
.findFirst()
.getAsLong();