
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Find the Last Digit of a Number
								Certification: Basic Level
								Accuracy: 74.84%
								Submissions: 159
								Points: 5
							
							Write a Python program that finds the last digit of a given integer.
Example 1
- Input: 12345
- Output: 5
- Explanation: 
    - Step 1: Take the input number 12345.
- Step 2: Calculate 12345 % 10 = 5 to get the last digit.
- Step 3: Return 5 as the result.
 
Example 2
- Input: -6789
- Output: 9
- Explanation: 
    - Step 1: Take the input number -6789.
- Step 2: Calculate abs(-6789) = 6789 to get the absolute value.
- Step 3: Calculate 6789 % 10 = 9 to get the last digit.
- Step 4: Return 9 as the result.
 
Constraints
- -10^9 ≤ number ≤ 10^9
- For negative numbers, return the absolute value of the last digit
- Time Complexity: O(1)
- Space Complexity: O(1)
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Use modulo operator: abs(number) % 10
- Convert to string and get last character: int(str(abs(number))[-1])
- Use math.fmod() for floating point numbers: int(abs(math.fmod(number, 10)))
- Create a function: def last_digit(num): return abs(num) % 10
