HP18 lucky number - showing error has NoSuchElementFound

Hi
My code works perfectly in IDE and here it is showing NoSuchElementFound error. How could this be?

I’m also getting the same error :frowning:

NoSuchElementException generally occurs in Java when Scanner is used in a wrong way.

The most common mistake is when Scanner is re-initialized in a function after every function call.

One possible solution is to create a global Scanner or creating it in Main and passing it as argument to the functions.

tried this also but not working

//