In this post, we will understand what is Nelson number? and how to check whether a number is Nelson in Java?

In cricket, the number 111 is sometimes called “a Nelson” after Admiral Nelson, who allegedly only had “One Eye, One Arm, One Leg” near the end of his life. This is, in fact, inaccurate—Nelson never lost a leg.

So the number 111 is called a nelson number and multiple of nelson are called double Nelson (222), triple Nelson (333) and so on.

We need to note that multiples of 111 are Nelson numbers e.g 111, 222, 333, 444, 555, 666, 777, 888 and 999. Not any other number which is divisible by 111.

Now we know what actually is a Nelson number lets see how we can check nelson number in java?

We need to use if-else for every multiple of 111, if the input number satisfies any condition then we output that the given number is a nelson number.

output

Java output for nelson number

That’s all for the Nelson number if you have any suggestions or doubts then please comment below.

Leave a Reply