I ran the same test code as for the rest. A long is up to 9223372036854775807 in value so a While loop will require up to 19 iterations for the biggest numbers. My test only uses Int so would need up to 9 iterations. Your test is really only going up to a maximum of 5 iterations. As only 1 of the numbers would return 6.