Return last 5 digits of a number

前端 未结 3 771
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 05:31

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

Example input:

123456789

Would return: 56789

3条回答
  •  臣服心动
    2021-02-14 05:40

    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).

提交回复
热议问题