惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Jina AI
Jina AI
H
Help Net Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
L
LangChain Blog
Recorded Future
Recorded Future
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
GbyAI
GbyAI
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
B
Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
The Cloudflare Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园 - 【当耐特】
T
Troy Hunt's Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google Online Security Blog
Google Online Security Blog
The GitHub Blog
The GitHub Blog

博客园 - 天生舞男

多个平均数列的子查询 迁移sharepoint Sharepoint迁移数据库之绝版(只要照着做,一定能够迁移成功) Sharepoint的webpart 虚函数和非虚函数的调用基本原则 The visio to drawing project chart. - 天生舞男 Using MSChart from a C# WinForm About the deeply copy 学习程序的自我建议---从实际软件的源代码开始学习 MS bug "The connection pool" in Oracle 10g and the data sort according to specified filed on DataGrid control. How to get response content with specified post data by post method Post method tip automation服务器不能创建对象 rose破解 ArrayList按Index删除的问题 Recently expection RadioButtonList中选择框和文字对不齐的解决办法 resolve problem best method is find document from official document 看了宝玉的作品,心理甚是感叹
Get the biggest common divisor
天生舞男 · 2006-02-21 · via 博客园 - 天生舞男

// 我们可以从两个数的比较小的那个开始,看看时候可以同时整除这两个数,如果可以,那么就是结果。
  // 如果不行,我们就把它减一,再试。一直到减到1,这时一定是可以整除的。
  /*
  public static int GetBigestCommonDivisor(int x, int y)
  {
   int nresult;
   if (x > y)
    nresult = y;
   else
    nresult = x;
   for (;nresult > 1;nresult --)
   {
    if ((x % nresult) == 0 && (y % nresult) == 0)
     break;
   }
   return nresult;
  }
  */

  // 首先我们假设结果是两个数中小的那一个是结果,用它去除比较大的数,如果余数是0,
  // 那么它就是结果。如果不是0,那么我们就把这个余数假设为结果,把原来小的那个数作为验证的被除数,再进行验证。直到找到结果。
  public static int GetBigestCommonDivisor(int x, int y)
  {
   int ntemp;
   // Ensure x > y
   if (x < y)
   {
    ntemp = x;
    x = y;
    y = temp;
   } 

   while (y > 1)
   {
    temp = x % y;
    if (ntemp == 0)
     break;
    x = y;
    y = ntemp;
   }
   return y;
  }