Improved Item 3 (1)--seeking greatest common divisor

Source: Internet
Author: User
Tags greatest common divisor

Tasks and Requirements

/**copyright (c) 2016,CSDN College *all rights reserved.* file name: lzz.c*    Creator: Linzeze * Completion Date: May 8, 2016 * version number: v1.0* Problem Description: Ask greatest common divisor (1) to enter two numbers and find out its greatest common divisor. Please write out the function of greatest common divisor (2) on the basis of the above program, increase the function GCDs function declaration and definition, to achieve the function of 4 number greatest common DIVISOR * Program input * Program output: */#include <stdio.h>int gcd (int x,int y)// Defines a function that is used to greatest common divisor a number of two, and the function evaluates the value regardless of the output. The output is completed by main {    int r=x%y;    while (r!=0)    {        x=y;        Y=r;        r=x%y;    }    return y;} int main () {    int a,b,g;    scanf ("%d%d", &a, &b);    G=GCD (A, b);    printf ("Greatest common divisor is:%d\n", g);    return 0;}
Run results



Improved Item 3 (1)--seeking greatest common divisor

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.