/* div_t Structure used to represent the value of an integral division performed by div. It has two members of the same type, defined in either order as: int quot; int rem; Members: quot Represents the quotient of the integral division operation performed by div, which is the integer of lesser magnitude that is neares to the algebraic quotient. rem Represents the remainder of the integral division operation performed by div, which is the integer resulting from subtracting quot to the numerator of the operation. div function<cstdlib>div_t div ( int numerator, int denominator ); ldiv_t div ( long numerator, long denominator ); Integral division Returns the integral quotient and remainder of the division of numerator by denominator as a structure of type div_t or ldiv_t, which has two members: quot and rem. Return Value The result is returned by value in a structure defined in <cstdlib>, which has two members. For div_t, these are, in either order: int quot; int rem; and for ldiv_t: long quot; long rem; Portability In C, only the int version exists. Example #include <stdio.h> #include <stdlib.h> int main () { div_t divresult; divresult = div (38,5); printf ("38 div 5 => %d, remainder %d./n", divresult.quot, divresult.rem); return 0; } Output: 38 div 5 => 7, remainder 3. */ #include <iostream> #include <numeric> #include <vector> using namespace std; int main() { vector< int > n; n.push_back( 2 ); for ( int i = 0; i < 333; i++ ) { div_t r = { 0, 0 }; for ( int j = 0; j < n.size(); j++) { r = div( 8 * n[ j ] + r.quot, 10 ); n[ j ] = r.rem; } if ( r.quot != 0 ) n.push_back( r.quot ); } cout << "Sum = " << accumulate( n.begin(), n.end(), 0 ) << endl; }