0
点赞
收藏
分享

微信扫一扫

更卷的2024,如何把短剧产品做的更好?| TopOn出海干货

一世独秀 04-11 21:30 阅读 0

辗转相除求最大公约数

#include<iostream>
using namespace std;

int gcd(int a, int b)//求最大公约数,如果返回值为1,最大公约数只有1,为所求
{
	return b ? gcd(b, a % b) : a;
}
int main()
{
	int count = 0;
	for(int i=1;i<=2020;i++)
		for (int j = 1; j <=2020; j++)
		{
			if (gcd(i, j) == 1)
				count++;
			
		}
	cout << count << endl;
	return 0;
}
举报

相关推荐

0 条评论