# Check if the last digit in a 4 digit number is a 1

Is there a way to check if the last digit of a 4-digit (or any digit) number is a 1?

I am trying to make something that checks if the first and last digit of a number are both 1. Suppose our number is 1581. To check if the first digit is 1 is trivial. I can go..

if number - 2000 < 0 AND number - 999 > 0, then the first digit is always one.

Is there a test similar to above to check if the last digit is 1?

EDIT: Just to add more context to the question, we want to find an automated way to check if the number starts and ends with a 1.

• What do you mean? If you have the number, you can just look at the last digit. If you want something that sounds fancier, just take the remainder on division by $10$.
– lulu
May 30, 2020 at 21:24
• This is part of an authentication license key that will be installed in our cloud to monitor for our applications. After decoding our provided license key, the 1st and last digit should always be 1. There will be thousands of customers and the key validation engine is a basic calculator that can only do floating point operations such as add, subtract, multiply, and divide May 30, 2020 at 21:27
• Does it have a MOD command? Somthing like MOD(1481,10) =1 May 30, 2020 at 21:36
• @RuiNian Why don't you just cast it to a string and verify directly? May 30, 2020 at 21:38
• Or FLOOR or INT that gives the integer part, then $1481-10×FLOOR(1481/10)=1$ May 30, 2020 at 21:39

If it has MOD then something like $$MOD(1481,10)=1$$.
If it has FLOOR or INT to give the integer part, then $$1481-10×FLOOR(1481/10)=1$$
$$1000 \le x < 2000 \land x \mathrel{\mbox{mod}} 10 = 1$$