题解 | #求最小公倍数#

求最小公倍数

https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3

using System;

class Solution{
    public static void Main(){
        var array = Console.ReadLine().Split(' ');
        int input_1 = Convert.ToInt32(array[0]);
        int input_2 = Convert.ToInt32(array[1]);
        int res = input_1*input_2/ GetValue(input_1,input_2);
        Console.WriteLine(res.ToString());
        
    }
    
    public static int GetValue(int a, int b){//最大公约数,辗转相除法
       if(b == 0) return a;
        int temp = a;
        a = b;
        b = temp % b;
        return GetValue(a,b);
    }
}

全部评论

相关推荐

代码飞升:别用口语,后端就写后端,前端就写前端,最后别光后悔
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务