Skip to content

Reverse the number by different approaches in many programming languages(that I know)

Notifications You must be signed in to change notification settings

TokisakiKurumi2001/reversing_number

Repository files navigation

reversing_number

Reverse the number by different approach

Old approach:

Modulo and integer divide to get the number

Advantage:

  • Simple, arithmetic operation required

Disadvantage:

  • Dealing with long number seems to be very hard to achieve

New approach:

Using built-in function:

Convert number to string and use built-in function to reverse the string then return

Advantage:

  • Dealing with big number is a piece of cake

Disadvantage:

  • Some programming language doesn't have built-in reverse string function
  • Require some simple knowledge when dealing with string

Handmade reverse function:

Instead of using built-in function, we implement our own reverse function

Advantage:

  • Like using built-in function

Disadvantage:

  • Dealing string in some low-level programming language may require strong basic CS knowledge