Untitled
unknown
plain_text
a year ago
472 B
17
Indexable
#include <stdio.h> int main() { int num, n; printf("Enter number: "); scanf("%d",&num); printf("Enter n: "); scanf("%d",&n); for (int j = n; j > 0; j--) { int i, gcd; for(i=1; i <= j && i <= num; ++i) { // Checks if i is factor of both integers if(num%i==0 && j%i==0) gcd = i; } printf("GCD of %d and %d is %d\n", j, num, gcd); } return 0; }
Editor is loading...
Leave a Comment