Given two integers a and b. The task is to concatenate these two integers into one integer.
Input : a = 806, b = 91 Output : 8691 Input : a = 5, b = 1091 Output : 51091
Method 1: One method of achieving this can be counting the number of digits of second number. Then multiply the first number with 10^digits and adding both the numbers. Below is the implementation.
Method 2: Another method can be converting both the numbers to the string. Then concatenate them and convert them back to integers. Below is the implementation.
- Python - Concatenate Dictionary string values
- Python | Ways to convert Boolean values to integer
- Python Program to Count set bits in an integer
- Python program to find the highest 3 values in a dictionary
- Python program to Swap Keys and Values in Dictionary
- Python program to fetch the indices of true values in a Boolean list
- Python | Concatenate All Records
- Program to print all distinct elements of a given integer array in Python | Ordered Dictionary
- Python | Ways to concatenate two lists
- Python | Concatenate dictionary value lists
- Python | Numpy np.ma.concatenate() method
- Python | Ways to concatenate tuples
- Python | Ways to concatenate boolean to string
- Python - Concatenate Kth element in Tuple List
- Python | Concatenate two lists element-wise
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.