Question: 3. Two integers are considered to be relatively prime if there exists no integer greater than 1 that divides into them both. For example,

3. Two integers are considered to be relatively prime if there exists

 

3. 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 [])%;B 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)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!