package com.xiaowu.demo;

/**
* 输入两个正整数m和n,求其最大公约数和最小公倍数。
*
* @author WQ
*
*/
public class Demo6 {
public static void main(String[] args) {
int a = 5;
int b = 10;
int max = f(a, b);
int min = a * b / max;
System.out.println("最大公约数:" + max + " 最小公倍数:" + min);
} public static int f(int x, int y) {
int t;
if (x < y) {
t = x;
x = y;
y = t;
}
while (y != 0) {
if (x == y) {
return x;
} else {
int k = x % y;
x = y;
y = k;
}
}
return x;
}
}

最新文章

  1. linux git安装及配置(包括更新)
  2. Mysql Error: Host ‘xxx.xxx.xxx.xxx’ is not allowed to connect to
  3. python Django教程 之模板渲染、循环、条件判断、常用的标签、过滤器
  4. 实现UniqueAttribute唯一性约束-优化版
  5. C语言中指针的使用
  6. NGUI 的使用教程与实例(入门)(1 )
  7. 【Linux】lvm基础操作
  8. (一)关于java泛型的学习总结(泛型方法、泛型擦除)
  9. php版本的选择
  10. bzoj 1835: [ZJOI2010]base 基站选址
  11. python基础练习题
  12. 【源码解析】Sharding-Jdbc的执行过程(一)
  13. 解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
  14. 我对SQL性能优化的看法,对我的文章有提议的欢迎评论!
  15. MySQL 必知必会学习笔记(常用命令一)
  16. 中性SNP的突变年龄评估(estimate the average age of a neutral two-allele polymorphism)
  17. VC常用小知识
  18. python packaging
  19. Android实现中文汉字笔划(笔画)、中文拼音排序、英文排序
  20. 浅析Spring框架之一(Spring简介)

热门文章

  1. hdu1877进制转换
  2. nagios服务端安装
  3. Android初学者必知会的编程规范
  4. [洛谷P4346][CERC2015]ASCII Addition
  5. [xsy1129] flow [树链剖分和线段树一起优化网络流][我也不知道这是什么鬼标签]
  6. Crash的游戏 [组合+递推]
  7. poj 3311 floyd+dfs或状态压缩dp 两种方法
  8. code forces 996BWorld Cup
  9. Java面试题之类的静态代码块和静态属性等的加载顺序
  10. BZOJ 2103/3302/2447 消防站 树的重心【DFS】【TreeDP】