14743 - Counting the number of coprime numbers   

Description

Refer to Example 5.5 and write a program to calculate how many pairs of numbers are coprime among n given numbers.
We can rewrite Example 5.5 into a function to determine whether two numbers are coprime, which will speed up program development.

The input consists of one line containing n positive integers.
The output is the number of pairs of coprime numbers among these n integers.

Constraint: 0 < n <= 100

 

Example 5.5 Calculate the greatest common factor of i and j

#include <stdio.h>
main()
{
    int i, j, k;
    scanf("%d", &i);
    scanf("%d", &j);
    while (i % j != 0) {
        k = i % j;
        i = j;
        j = k;
    }
    printf("%d\n", j);
}


Input
72
56

Output
8

Input

A line of n positive integers.

Ex. 23 76 34 12 7 5 34

Output

Numbers of pairs of numbers among these n positive integers that are coprime.

Ex. 16

 

Sample Input  Download

Sample Output  Download




Discuss