You are given two positive number n and m. You have to find simply addition of both number but with a given condition that there is not any carry system in this addition. That is no carry is added at higher MSBs.
Input : m = 456, n = 854 Output : 200 Input : m = 456, n = 4 Output : 450
To solve this problem we will need the bit by bit addition of number where we start adding two number from right most bit (LSB) and add integers from both nubers with same position. Also we will neglect carry at each position so that that carry will not affect further higher bit position.
Start adding both numbers bit by bit and for each bit take sum of integers then neglect their carry by taking modulo of bit_sum by 10 further add bit_sum to res by multiplying bit_sum with a multiplier specifying place value. (Multiplier got incremented 10 times on each iteration.)
Below is the implementation of above approach :
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Convert numbers into binary representation and add them without carry
- Count of carry operations on adding two Binary numbers
- Position of rightmost bit with first carry in sum of two binary
- Bitwise recursive addition of two integers
- BCD addition of given Decimal numbers
- Modify array by merging elements with addition such that it consists of only Primes.
- How to swap two numbers without using a temporary variable?
- Add two numbers without using arithmetic operators
- Subtract two numbers without using arithmetic operators
- Check if two numbers are equal without using arithmetic and comparison operators
- Check if two numbers are equal without using comparison operators
- Fast average of two numbers without division
- Smallest string without any multiplication sign that represents the product of two given numbers
- Compute the minimum or maximum of two integers without branching
- Find XOR of two number without using XOR operator
- Compare two integers without using any Comparison operator
- Divide two integers without using multiplication, division and mod operator
- Count of N-bit binary numbers without leading zeros
- Compute the integer absolute value (abs) without branching
- Smallest of three integers without comparison operators
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.