Euclidean Algorithm for maximum public Factor Calculation

Source: Internet
Author: User
Euclidean Algorithm for maximum public Factor Calculation



By continuously calculating the remainder, the algorithm knows that the remainder is zero and the non-zero remainder is the maximum public factor.



/***************************************************code writer:EOFcode file:gcd.ccode date:2014.09.18e-mail:[email protected]description:This is a implementation of GCD :)If there is something wrong with my code,please touch me by e-mail. Thank you.****************************************************/unsigned int gcd(unsigned int x,unsigned int y){unsigned int rem = 0;/***set the bigger one as "x"** the smaller one is "y".*/if(x < y){rem= x;x   = y;y= rem;}/***The min non-zero reminder is GCD.*/for(rem = 0; y > 0;){rem = x % y;x = y;y = rem;}return x;}

Test procedure:

#include <stdio.h>#include "gcd.h"int main(){printf("gcd(1989,1590) :%d\n",gcd(1989,1590));return 0;}



Danding's boat delakova 1822 oil painting 189x246 cm Paris Louvre


The oil painting "Dante boat" (also translated "Dante and vijir crossing the river") created by delakrova in 1822, based on the masterpiece of Dante "Divine Comedy". On the screen, vigill, the poet wearing a laurel garlands, is guiding his partner Dante to take a boat through hell; the head of the ship, a naked man wrapped in a long blue cloth, shook his head. In the river with waves turning over, a few who were fined into the hell grabbed the boat and did not put it; there was also a woman, the water was shining on her body. From a closer look, the splash of water flowers are actually red-green complementary colors of yellow and white paint points. Such refined techniques and real results cannot but surprise viewers. Artist Shi believes that the tragic feeling of "Dante boat" is the memory of Kiki and rubence, the stubborn personality of the painter demonstrated by the painter laid the pioneer position in the French romantic school of painting.



Euclidean Algorithm for maximum public Factor Calculation

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.