+ 4
The problem is in `Math.pow(s, strNum.length())` Here, `s` is of type char. When you pass `s` to Math.pow(), it will be implcitly converted to int, which will be the ascii value of the character. For example, if the input was "153" and `s` has the value '1', then the result of the call to Math.pow() will be '1' ^ 3 = 49 ^ 3 ('1' converted to its ascii value) = 117649 You can get the numeric value stored in 's' by using the Character.getNumericValue() method. So the call to Math.pow() will be changed to `Math.pow( Character.getNumericValue(s), strNum.length() )`
3rd May 2021, 9:43 AM
XXX
XXX - avatar