Find the 15 first positive integers, which are totally dividing by 19 and being in the interval, the left border of which is 100. In С ++ Visual Studio.
|
2 answers
Search for the first 15 numbers divisible by 19 with no remainder in the interval, the left boundary of which is 100.
#include <iostream> int main() { int k = 100 / 19 + 1; for ( int i = k; i < k + 15; i++ ) std::cout << 19*i << " "; std::cout << std::endl; return 0; }
|
Somewhat more complicated solution than the previous one:
const double max_num = std::numeric_limits< double >::max(); const double epsilon = std::numeric_limits< double >::epsilon(); const double divider = 19.; std::vector< double > targets_numbers; for (double num = 100.; (num < max_num) && (targets_numbers.size() < 16); num++) { const double reminder = num % divider; if ( fabs(reminder) <= epsilon ) targets_numbers.push_back( num ); }
- and what, the increment is applicable to double variables? - renegator
- yes, applicable. - vladimir_ki Nov.
- and division by module? - renegator
|