Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write code in C language The gcd of a list of numbers is the largest number that

ID: 646356 • Letter: W

Question

write code in C language

The gcd of a list of numbers is the largest number that evenly divides all of the elements in that list. For example, the gcd of 12 20 30 40 is 2. Write a program that takes in an arbitrary number of integers as commandline arguments and prints the gcd of that list.

Sample session:> ./a.out 101
101
> ./a.out 12 18 30
6
> ./a.out 12 18 30 36
6
> ./a.out 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
1

You may assume that at least one number is given, that the given numbers are integers, and that they are all positive (i.e. greater than 0.)

Explanation / Answer

using Euclid's Algorithm.

Note:     argc - Number of arguments in the command line including program name
             argv[]