I am supposed to write a function which computes the next integer in a sequence from the given one.
For example:
nextval[57]
should give mm
74
I need to make sure this function checks for positive integers, and I need use the Mathematica function IntegerDigits
, which returns a list of the individual digits of any integer n
.
For example:
IntegerDigits[57]
{5, 7}
The overview of this is to basically take any positive integer, say 57, square the individual digits and add them to get a new integer.
5^2 + 7^2 = 25 + 47 = 74
I know I am supposed to make function using Module
, but might it also use an If
statement?