Return last 5 digits of a number

前端 未结 3 560
栀梦
栀梦 2021-02-14 05:17

How do you only display the last 5 digits of a number?

Example input:

123456789

Would return: 56789

3条回答
  •  甜味超标
    2021-02-14 05:38

    One approach is to do the following:

    1) Convert the number to a string
    2) Make sure the string has more than 5 digits.
    3) If it does, get the last five characters in the string.

    The above three steps have links that show you how implement them. Since this is homework, getting it to work is left as an exercise (channeling my former TA).

提交回复
热议问题