Question: 8 . [ 4 marks ] Recall the bijection between the positive rational numbers Q and the positive integers N . Write a C program

8.[4 marks] Recall the bijection between the positive rational numbers Q and the positive integers N . Write a C program to output the rational number that gets mapped to n. Remember, to skip over the fractions that are not in reduced form. For example, the first 11 such rational numbers are:
1/1,2/1,1/2,3/1,1/3,4/1,3/2,2/3,1/4,5/1,1/5
Hand in: Your C code and output the n-th rational numbers for:
(a) n =11(should be 1/5)
(b) n =999
(c) n =1234567
(d) n =87654321
(e) n =999999999(nine 9s, my implementation took about 3 minutes)

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 Programming Questions!