Reverse a Number
Reverse a Number
Tags: Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes a positive integer N and returns its reverse using a while loop. This problem is designed to help you practice using while loops and working with numbers
. The function should accept one parameter and return the reversed number.
Constraints:
- The input will be a positive
integer
greater than zero. - The function should
return
aninteger
representing the reversed number.
Example:
- Input:
1234
- Output:
4321
Test Case | Input | Expected Output |
---|---|---|
1 | 1234 | 4321 |
2 | 1 | 1 |
3 | 1000 | 1 |
4 | 9876543210 | 0123456789 |
Leave a Comment
Please login to leave a comment.