Given a large number (represented as a string) which has to divide by another number (represented as int data type). The large number can be very large which does not even fit in long long in C++. The task is to find the division of these numbers.
Input : number = 1260257 divisor = 37 Output : 34061 (See below diagram) Input : number = 12313413534672234 divisor = 754 Output : 16330787181262 Input : number = 1248163264128256512 divisor = 125 Output : 9985306113026052
We have already discussed Multiply Large Numbers represented as Strings.
We use basic school mathematics as shown in below example.
As the dividend and result can be very large we store them in string. We first take digits which are divisible by number. After this take each digit and store result in string.
This article is contributed by nuclode. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Square of large number represented as String
- Multiply Large Numbers represented as Strings
- Modulo power for large numbers represented as strings
- Number of ways to divide string in sub-strings such to make them in lexicographically increasing sequence
- Evaluate a boolean expression represented as string
- Product of nodes at k-th level in a tree represented as string
- Reverse all the word in a String represented as a Linked List
- Product of nodes at k-th level in a tree represented as string using Recursion
- Modulo of a large Binary String
- Number of factors of very large number N modulo M where M is any prime number
- Divide a string in N equal parts
- Find smallest possible Number from a given large Number with same count of digits
- Check whether a number can be represented by sum of two squares
- Count of possible permutations of a number represented as a sum of 2's, 4's and 6's only
- Check if a number can be represented as sum of non zero powers of 2
- Find count of digits in a number that divide the number
- Find the number of ways to divide number into four parts such that a = c and b = d
- Count number of ways to divide a number in 4 parts
- Check if a given number can be represented in given a no. of digits in any base
- Number of ways in which N can be represented as the sum of two positive integers