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