最小公倍数=两个数的乘积/两个数的最大公约数。

接上篇求最大公约数方法,最小公倍数的代码例如以下:

public class LCM {
//最小公倍数=两数乘积/最大公约数
public static int lcm(int m, int n){
return m*n/GCD.gcd(m,n);
}
public static void main(String[] args){
System.out.println(lcm(0,9));
}
}

结果:

0

最小公倍数(Least Common Multiple)的更多相关文章

  1. 26最小公倍数 lowest common multiple

    题目描述 正整数A和正整数B 的最小公倍数是指 能被A和B整除的最小的正整数值,设计一个算法,求输入A和B的最小公倍数. 输入描述:输入两个正整数A和B. 输出描述:输出A和B的最小公倍数. 输入例子 ...

  2. hdu 2028 Lowest Common Multiple Plus(最小公倍数)

    Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  3. HDOJ 1019 Least Common Multiple(最小公倍数问题)

    Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...

  4. hdu_1019Least Common Multiple(最小公倍数)

    太简单了...题目都不想贴了 //算n个数的最小公倍数 #include<cstdio> #include<cstring> #include<algorithm> ...

  5. 最大公约数最小公倍数 (例:HDU2028 Lowest Common Multiple Plus)

    也称欧几里得算法 原理: gcd(a,b)=gcd(b,a mod b) 边界条件为 gcd(a,0)=a; 其中mod 为求余 故辗转相除法可简单的表示为: int gcd(int a, int b ...

  6. HDU - 1019-Least Common Multiple(求最小公倍数(gcd))

    The least common multiple (LCM) of a set of positive integers is the smallest positive integer which ...

  7. zoj1797 Least Common Multiple 最小公倍数

    Least Common Multiple Time Limit: 2 Seconds      Memory Limit: 65536 KB The least common multiple (L ...

  8. HDU1019 Least Common Multiple(多个数的最小公倍数)

    The least common multiple (LCM) of a set of positive integers is the smallest positive integer which ...

  9. 题目1439:Least Common Multiple(求m个正数的最小公倍数lcm)

    题目链接:http://ac.jobdu.com/problem.php?pid=1439 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  10. (杭电1019 最小公倍数) Least Common Multiple

    Least Common Multiple Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...

随机推荐

  1. java复习之基础环境

    环境基本介绍: JDK(Java Development Kit) 是 Java 语言的软件开发工具包(SDK).在JDK的安装目录下有一个jre目录,里面有两个文件夹bin和lib,在这里可以认为b ...

  2. 树形 dp

    // ACM训练联盟周赛     C. Teemo's tree problem There is an apple tree in Teemo's yard. It contains n nodes ...

  3. Java-从一个字符串获取子字符串

    substring函数 package com.tj; public class MyClass implements Cloneable { public static void main(Stri ...

  4. 大数据学习——Storm+Kafka+Redis整合

    1 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="h ...

  5. 【转】Python3学习笔记(urllib模块的使用)

    原文地址:https://www.cnblogs.com/Lands-ljk/p/5447127.html 1.基本方法 urllib.request.urlopen(url, data=None,  ...

  6. 有关C语言指针访问问题

    C语言指针访问问题今天有了一些理解. char *p; char *q; char k[10000]; 我之前一直以为他们两个一样用,因为之前看到说k也是一个地址,我忽略了后面的一句话,k是连续的一段 ...

  7. ubuntu系统下如何禁用笔记本触摸板

    命令行方式,得每次用终端输入命令行设置,不方便. sudo rmmod psmouse          # 用来禁用触摸板 sudo modprobe psmouse     # 用来启用触摸板 想 ...

  8. 九度oj 题目1021:统计字符

    题目描述:     统计一个给定字符串中指定的字符出现的次数. 输入:     测试输入包含若干测试用例,每个测试用例包含2行,第1行为一个长度不超过5的字符串,第2行为一个长度不超过80的字符串.注 ...

  9. tomcat在centos6+上的自启动脚本

    #!/bin/bash # # tomcat startup script for the Tomcat server # # chkconfig: 345 80 20 # description: ...

  10. 【kmp+最小循环节】poj 2406 Power Strings

    http://poj.org/problem?id=2406 [题意] 给定字符串s,s=a^n,a是s的子串,求n最大是多少 [思路] kmp中的next数组求最小循环节的应用 例如 ababab ...