当前位置:网站首页>Chapter 2: find the classical solution of the maximum Convention and the least common multiple of a and B, find the conventional solution of the maximum Convention and the least common multiple of a a
Chapter 2: find the classical solution of the maximum Convention and the least common multiple of a and B, find the conventional solution of the maximum Convention and the least common multiple of a a
2022-07-03 19:21:00 【Shares_ four】
// seek a,b Classical solution of maximum Convention and least common multiple of
int main()
{
long a, b, c, r, a1, b1;
printf(" Please enter a positive integer a,b: ");
scanf("%ld,%ld", &a, &b);
if (a < b)
{
c = a;
a = b;
b = c;
}
a1 = a;
b1 = b;
r = a % b;
while (r != 0) // The implementation of “ division algorithm
{
a = b;
b = r;
r = a % b;
}
printf("(%ld,%ld) = %ld\n", a1, b1, b);
printf("{%ld,%ld} = %ld\n", a1, b1, a1 * b1 / b);
return 0;
}
result :
// seek a,b The conventional solution of the maximum Convention and the least common multiple of
int main()
{
long a, b, c;
printf(" Please enter a positive integer a,b: ");
scanf("%ld,%ld", &a, &b);
if (a < b)
{
c = a;
a = b;
b = c;
}
for (c = b; c >= 1; c--)
if (a % c == 0 && b % c == 0) break; //C Is the trial quotient factor
printf("(%ld,%ld) = %ld\n", a, b, c);
printf("{%ld,%ld} = %ld\n", a, b, a * b / c);
return 0;
}
result :
// seek n The maximum Convention and the least common multiple of positive integers
int main()
{
int k, n;
long a, b, c, m[100];
printf(" Please enter the number of positive integers n: ");
scanf("%d", &n);
printf(" Please input... In turn %d A positive integer :", n);
for (k = 0; k <= n - 1; k++)
{
printf("\n Please enter the first %d A positive integer :", k + 1);
scanf(" %ld", &m[k]); // Input raw data
}
b = m[0];
for (k = 1; k <= n - 1; k++) // Cycle calculation n - 1 Time
{
a = m[k];
if (a < b)
{
c = a;
a = b; // In exchange for a、b, Make sure a>b
b = c;
}
for (c = b; c >= 1; c--)
if (a % c == 0 && b % c == 0) break; // Calculate the greatest common divisor
if (c == 1) break; // If the greatest common divisor is 1, Exit loop
b = c;
}
printf(" (%ld", m[0]); // Output the result of the greatest common divisor
for (k = 1; k <= n - 1; k++)
printf(", %ld", m[k]);
printf(") = %ld\n", c);
b = m[0];
for (k = 1; k <= n - 1; k++) // Cycle calculation n-1 Time
{
a = m[k];
if (a < b)
{
c = a;
a = b;
b = c;
}
for (c = a; c <= a * b; c = c + a)
if (c % b == 0) break;
b = c;
}
printf("{%ld", m[0]);
for (k = 1; k <= n - 1; k++)
printf(",%ld", m[k]);
printf("}=%ld\n", c);
return 0;
}
result :
边栏推荐
- Ego planner code parsing Bspline_ Optimizer section (3)
- 【水质预测】基于matlab模糊神经网络水质预测【含Matlab源码 1923期】
- How to build an efficient information warehouse
- Succession of flutter
- Simple solution of physical backup and restore of Damon database
- The space of C disk is insufficient, and the computer becomes stuck. Quickly expand the capacity of C disk to make the system more smooth
- SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
- [optics] vortex generation based on MATLAB [including Matlab source code 1927]
- 第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘
- Sentinel source code analysis part II - sentinel dashboard console startup and configuration
猜你喜欢

第一章:三位阶乘和数,图形点扫描

Php based campus lost and found platform (automatic matching push)
![[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time](/img/06/5a37e2dca9711f8322b657581c3d75.png)
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time

PyTorch中在反向传播前为什么要手动将梯度清零?
![[optics] dielectric constant calculation based on MATLAB [including Matlab source code 1926]](/img/cb/ee696d5a7d6bef96fe0db89e8478ed.jpg)
[optics] dielectric constant calculation based on MATLAB [including Matlab source code 1926]

第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数

The necessity of lean production and management in sheet metal industry

I study database at station B (4): DQL

Chapter 2: 4-digit Kaplan number, search even digit Kaplan number, search n-digit 2-segment sum square number, m-digit ingenious square number without 0, specify the number to form a 7-digit square nu

Day_ 18 IO stream system
随机推荐
Yolov3 network model building
Counting from the East and counting from the West will stimulate 100 billion industries. Only storage manufacturers who dare to bite the "hard bone" will have more opportunities
Random numbers in a long range, is that right- Random number in long range, is this the way?
Using the visualization results, click to appear the corresponding sentence
[leetcode] [SQL] notes
【LeetCode】【SQL】刷题笔记
Merge K ascending linked lists
05 -- QT OpenGL draw cube uniform
PyTorch中在反向传播前为什么要手动将梯度清零?
Comments on flowable source code (37) asynchronous job processor
High concurrency Architecture - read write separation
记录在模拟器中运行flutter时报的错
[wallpaper] (commercially available) 70 wallpaper HD free
Recommend a GIF processing artifact less than 300K - gifsicle (free download)
Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
Zhang Fei hardware 90 day learning notes - personal records on day 4, please see my personal profile / homepage for the complete
第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
Simulation scheduling problem of SystemVerilog (1)
P3402 persistent and searchable