"Huawei OJ" "067-seeking least common multiple"

Source: Internet
Author: User
Tags gcd

"Huawei OJ" "Algorithm Total chapter" "Huawei OJ" "067-seeking least common multiple" "Project download" topic description
正整数A和正整数B 的最小公倍数是指 能被A和B整除的最小的正整数值,设计一个算法,求输入A和B的最小公倍数。
Enter a description
输入两个正整数A和B。
Output description
输出A和B的最小公倍数。
Input example
57
Output example
35
Algorithm implementation
ImportJava.util.Scanner;/** * Author: Wang Junshu * date:2015-12-28 13:51 * All rights Reserved!!! */ Public  class Main {     Public Static void Main(string[] args) {Scanner Scanner =NewScanner (system.in);//Scanner Scanner = new Scanner (Main.class.getClassLoader (). getResourceAsStream ("Data.txt"));         while(Scanner.hasnext ()) {intm = Scanner.nextint ();intn = scanner.nextint ();        System.out.println (M/GCD (M, N) * n);    } scanner.close (); }Private Static int GCD(intMaxintMin) {inttmpif(Max < min)            {tmp = max;            max = min;        min = tmp; } while(max% min! =0) {tmp = min;            min = max% min;        max = tmp; }returnMin }}

"Huawei OJ" "067-seeking least common multiple"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.