Created
February 4, 2015 19:24
-
-
Save shohan4556/0d7929ce576f3f2900c0 to your computer and use it in GitHub Desktop.
Uva 11417 solution in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Author : Md.Shohanur Rahaman | |
| /// UVA -- 11417 (GCD) | |
| // Problem Type : Math - Easy | |
| #include<stdio.h> | |
| int gcd(int a,int b); | |
| int main() | |
| { | |
| int i,j,sum=0,n=0; | |
| while(scanf("%d",&n)==1){ | |
| if(n==0) | |
| break; | |
| sum=0; | |
| for(i=1;i<n;i++){ | |
| for(j=i+1;j<=n;j++){ | |
| sum+=gcd(i,j); | |
| } | |
| } | |
| printf("%d\n",sum); | |
| } | |
| return 0; | |
| } | |
| int gcd(int a,int b) | |
| { | |
| if(b==0) | |
| return a; | |
| else | |
| return gcd(b,a%b); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment