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

Two integers are considered to be relatively prime if there exists no integer gr

ID: 3615633 • Letter: T

Question

Two integers are considered to be relatively prime if there exists no integer greater than 1 that divides into them both. For example, the numbers 9 and 10 are relatively prime because there is no number (other than 1) that divides into them both (although the numbers themselves are non-prime). That is, the only numbers that divide into 9 are 3 and 9 (ignoring 1). Neither 3 nor 9 divide into 10. Write a program that obtains 2 integers from the user and determines whether they are relatively prime. Include in your program a function which determines the factors of an integer and puts the factors in an array - the prototype is: You do not need to include the factor 1 in the array. Use a sentinel value in the array to indicate where the factors finish. (Hint: you can use the function above to get the factors of one of the numbers, then use the contents of the factors [ ] array to divide into the second number in order to test if there's a common factor.)

Explanation / Answer

please rate - thanks #include #include void getFactors(int number,int factors[]); int main() {int n,m,i,factors[50]; printf("Enter 1st number you are checking: "); scanf("%d",&n); printf("Enter 2nd number you are checking: "); scanf("%d",&m); getFactors(n,factors); i=0; do {if(m%factors[i++]==0)      {printf("%d and %d are not relativelyprime ",n,m);       getch();       return 0;       } }while(factors[i]!=-1); printf("%d and %d are relatively prime ",n,m);       getch();       return 0; } void getFactors(int number,int factors[]) {int i,j=0; for(i=2;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote