Find the number after successive division | C ++ program to implement above approach ; Function to find the number ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findNum ( int div [ ] , int rem [ ] , int N ) { int num = rem [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) { num = num * div [ i ] + rem [ i ] ; } return num ; } int main ( ) { int div [ ] = { 8 , 3 } ; int rem [ ] = { 2 , 2 } ; int N = sizeof ( div ) / sizeof ( div [ 0 ] ) ; cout << findNum ( div , rem , N ) ; return 0 ; }