当前位置:网站首页>求其最大公约数和最小公倍数
求其最大公约数和最小公倍数
2022-04-21 07:43:00 【长街395】
package com.educoder.competition;
import java.util.*;
public class Case2 {
public static void main(String[] args) {
long a, b;
Scanner s = new Scanner(System.in);
a = s.nextLong();
b = s.nextLong();
long t;
long r;
long n;
/********** Begin *********/
if(a<b)
{t=b;b=a;a=t;}
r=a%b;
n=a*b;
while(r!=0)
{
a=b;
b=r;
r=a%b;
}
System.out.println("最大公约数: "+b);
System.out.println("最小公倍数: "+n/b);
/********** End *********/
}
}
版权声明
本文为[长街395]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_56301399/article/details/124157095
边栏推荐
猜你喜欢

Express architecture in nodejs

Redis (14) -- master-slave replication of redis

【C语言入门系列(8)(9)】第八、九章、指针、结构体

打卡:4.20 C语言篇 -(1)初识C语言 - (10)关键字typedef、static

C51通过esp8266连接onenet(MQTT协议)上传温湿度+控制LED

No .egg-info directory found in xxx\pip-pip-egg-info-mq

Vim这么难用,为啥这么多人热衷?

作文以记之 ~ 克隆图

堆叠柱状图加上折线图-echart图表(一)

Security settings of SQL Server database of SQL Server database
随机推荐
将excel数据向数据库里导入时失败怎么解决
MySQL忘记root密码解决方案
【面试普通人VS高手系列】b树和b+树的理解
Display selection reference ladder
Web漏洞详解:SQL注入漏洞
request与response对象
Vim这么难用,为啥这么多人热衷?
386 dictionary order number, learn to use the idea of recursion
Record the fuck string of C # to Base64 and Base64 restore string
ARM64体系结构编程与实践:算术与移位指令
HTTP缓存策略与方案
Final Cut Pro 在视频的多个地方同时打马赛克
Restful规范和使用
堆叠柱状图加上折线图-echart图表(一)
第七章 Select子句与子查询
打卡:4.20 C语言篇 -(1)初识C语言 - (10)关键字typedef、static
【C语言入门系列(8)(9)】第八、九章、指针、结构体
SQL Server 数据库之SQL Server 数据库的安全设置
pydeck助数百万数据点高效可视化渲染
第九章 用户与权限