Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"stdafx.h"
- #include"math.h"
- #include <iostream>
- using namespace std;
- unsigned int gcd(unsigned int a, unsigned int b) {
- unsigned int r;
- while (b != 0) {
- r = a%b;
- a = b;
- b = r;
- }
- return a;
- }
- int main() {
- unsigned int n, m;
- unsigned int nm;
- unsigned int lcm;
- unsigned int cm;
- setlocale(LC_CTYPE, "Rus");
- n = rand();
- m = rand();
- nm = n*m;
- lcm = n / gcd(n, m)*m;
- cout << "Общие кратные, меньшие n*m = " << nm << ":" << endl;
- for (cm = lcm; cm < nm; cm += lcm) {
- cout << cm << " ";
- }
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement