递归求最大公约数(GCD)
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
return b==0 ? a : gcd(b,a%b) ;
}
在此基础上求a和b的最小公倍数(LCM)
int lcm(int a,int b)
{
return a*b/gcd(a,b);
}
btw:分享两个VScode中快速注释代码技巧
1.ctrl + /
选中一块后快速给每一行加上
再按一次取消注释
2.alt + shift + a
选中一块后,在这一块的两端加上