Question: Problem2 programming in Fortran Consider the fraction, n/d , where n and d are positive integers. If n d and the greatest common divisor of

 Problem2 programming in Fortran Consider the fraction, n/d, where n and

Problem2 programming in Fortran

Consider the fraction, n/d, where n and d are positive integers. If nd and the greatest common divisor of n and d is 1 (GCD(n,d)=1), it is called a reduced proper fraction. (Note: the greatest common divisor is sometimes called the highest common factor. You may know it by this name.)

If we list the set of reduced proper fractions for d 8 in ascending order of size, we get:

1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8

There are 3 fractions between 1/3 and 1/2 as shown in bold.

Write a definition for a Fortran function named GCD that takes two positive integer arguments, a and b, and returns the greatest common divisor of a and b. (Hint: you can use the following result from mathematics. If a>b and the remainder when you divide a by b is r>0, then GCD(a,b)=GCD(b,r). If r=0, then GCD(a,0)=a.

Write a Fortran program to determine how many fractions lie between 1/3 and 1/2 in the set of reduced proper fractions for d 12,000? Your program must use the GCD function you defined in part (a). If you did not get part (a) correct you can still get full marks for this part

Question 27 Programming Euler's Triangle can be defined as a series of rows of width equal to the row number e. the first row has one column, the second row has two columns, etc.D. The indexing of Euler's Triangle, however, is such that the rows go from 1 to n, whereas the columns go from 0 to m. The leftmost and rightmost columns are always equal to 1. Numbers in between these ends are computed using the formula: E n, m n-m E n -1, m 1 m 1 E(n -1, m) Where n is the row (starts at 1) and m is the column (starts at 0) Your task is to read the number of rows of the triangle required from the user and output them to the screen. You can write the program in C or in Fortran. A sample output with the number of rows 8 is shown below 11 11 26 66 26 1 57 302 302 57 1 1 120 1191 2416 1191 120 1 1 247 4293 15619 15619 4239 247 1 The output must be done as shown above in terms of the number of values per row Question 27 Programming Euler's Triangle can be defined as a series of rows of width equal to the row number e. the first row has one column, the second row has two columns, etc.D. The indexing of Euler's Triangle, however, is such that the rows go from 1 to n, whereas the columns go from 0 to m. The leftmost and rightmost columns are always equal to 1. Numbers in between these ends are computed using the formula: E n, m n-m E n -1, m 1 m 1 E(n -1, m) Where n is the row (starts at 1) and m is the column (starts at 0) Your task is to read the number of rows of the triangle required from the user and output them to the screen. You can write the program in C or in Fortran. A sample output with the number of rows 8 is shown below 11 11 26 66 26 1 57 302 302 57 1 1 120 1191 2416 1191 120 1 1 247 4293 15619 15619 4239 247 1 The output must be done as shown above in terms of the number of values per row

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!