Misc CS Flashcards
1
Q
How to get the last digit of an integer without converting it to a string first
A
modulo 10
2013 % 10 ## 3
2
Q
How to get all digits but the last of an integer, without converting it to a string first
A
python
floor division by 10
Python
~~~
2013 // 10
# 201
~~~
Javascript
~~~
Math.floor(2013 / 10)
# 201
~~~