{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

07MoreArrays-handout

# 07MoreArrays-handout - More on Arrays Amir Hossein Rabbani...

This preview shows pages 1–8. Sign up to view the full content.

More on Arrays Amir Hossein Rabbani Winter 2009

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Array : Review Is the type of the values that can be stored in each element of the array Specifies the range of the indices for the subscript Type :: Name ( Bound ) REAL :: course_grades(10) course_grade(1) = 92 A1 A2 An-1 An 1 2 n-1 n Index elements
This session More examples on arrays Nested DO loop Implied DO loop

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
G C D G reatest C ommon D ivisor : the largest number that divides two integers Given two numbers a and b , and provided that a <= b , it is sufficient to divide both a and b by all numbers that are equal to or less than a . 204 12 x 17 12 ------- = ------------- = ------- 119 7 x 17 7
Example A B / A Common Divisor 12 18 / 12 - 11 18 / 11 - 10 18 / 10 - 9 18 / 9 - 8 18 / 8 - 7 18 / 7 - 6 18 / 6 6 = G C D 5 18 / 5 - 4 18 / 4 - 3 18 / 3 3 2 18 / 2 2 1 18 / 1 1 A = 12 B = 18

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
! Greatest Common Divisor PROGRAM GCD IMPLICIT NONE INTEGER :: A, B, counter IF (A <= B) THEN ! Finding minimum of A and B counter = A ELSE counter = B END IF DO IF (MOD(A , counter) == 0 .AND. MOD(B , counter) == 0) EXIT counter = counter - 1 END DO WRITE (*,*) “GCD of”, A, “ and “, B, “ is “, counter END PROGRAM GCD
How can I have all common divisors?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern