Reversing Digits of an Integer Algorithm O Level Python

Reversing Digits of an Integer Algorithm O Level Python

Reversing digits means changing the digits order backward. For Example

Input -   8672
Result - 2768 (Each digit places in reversed order)
To do this, divided the number by 10 and get the remainder like this.


You can get remainder by mod() also-

n = 8672 mod (10) = 2

Now remove 2 from the original integer number. So you get next number 867 (number to be reversed), again

n = 867 mod (10) = 7

Successively, find out the remainders until the dividend is less than 10. Now place the digits of remainders in reverse order.

Reversing Digits of an Integer Algorithm O Level Python

Algorithms-
  1. Begin
  2. Get any integer number to be reversed
  3. To do this, divided the number by 10 and get the remainder and write it in reverse order
  4. You can get remainder by mod() function by extracting the right most digit of the number 
  5. find out the remainders until the dividend is less than 10. Now place the digits of remainders in reverse order
  6. Stop

Post a Comment

0 Comments