Two integers are considered to be relatively prime if there exists no integer gr
ID: 3615767 • 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: void getFactors (int number, int factors[]); 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.) (30 marks)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;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.