MATH

FORTRAN ROGRAM THAT CAN ACCEPT TWO INTEGER NUMBERS AND COMPUTE AND DISPLAY ALL THEIR COMMON PRIME FACTORS

  1. 👍 0
  2. 👎 0
  3. 👁 170
  1. Surprised some school actually programmes in Fortran. NASA still does though. It's been a while since I last touched the language. If you have written the programme and run into difficulties, I can help you debug, syntax or logic.

    In fortran,
    read(5,*)I,J
    will read in two integers in free format.
    write(6,'2I5')I,J
    will write I and J up to 5 characters each.

    You can use Euclid's algorithm to find the highest common factor, namely:
    1. find the difference between I and J, call it K.
    2. Divide the smaller of I or J by K and call the remainder R.
    3. Replace the bigger of I or J by R and repeat 1 & 2 until R=0 or 1.
    If R=0, K is the GCF.
    If R=1, the GCF is 1 (i.e. no common factors).

    Example:
    I=80
    J=48
    K=I-J=32
    R=remainder of 48/32=1 R16

    I=16
    J=48
    K=48-16=32
    R=remainder of 16/32=0 R16
    I=16
    J=16
    GCF = 16 = 2^4

    1. 👍 0
    2. 👎 0
  2. thanks mathmate for your response.

    we were asked to use WATFOR77 compiler.i'm a newbee as far as programming is concern.

    can you pls. write the program the way i can run it in WATFOR77?

    thanks

    edwin

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. math (challenging)

    If R is the remainder when each of the numbers 1059, 1417, and 2312 is divided by D, where D is an integer greater than 1, compute the value of D-R

    asked by seth on September 30, 2009
  2. Big Data

    Suppose our input data to a map-reduce operation consists of integer values (the keys are not important). The map function takes an integer i and produces the list of pairs (p,i) such that p is a prime divisor of i. For example,

    asked by qwerty on October 6, 2014
  3. Ic

    Write an application that prompts the user for two integers and then prompts the user to enter an option as follows: 1 to add the two integers, 2 to subtract the second integer from the first, 3 to multiply the integers, and 4 to

    asked by Souad on April 24, 2016
  4. Math

    10. To find LCD by prime numbers, you should A. continue division until no prime number will divide into at least three numbers. B. take numerators and arrange in a row. C. divide numerators by the highest prime number. D. first

    asked by Diana on July 28, 2019
  5. college

    What will the following pseudocode program display? Module main( ) Declare Integer x = 1 Declare Real y = 3.4 Display x, " ", y Call changeUs(x, y) Display x, " ", y End Module Module changeUs(Integer a, Real b) { Set a = 0 Set b

    asked by timi on November 1, 2009
  1. PROBLEM SOLVING IN MATHEMATICS

    there are two prime numbers between 100 and 199 such that the ten digits is a prime number, the ones digit is a prime number and the tens and ones digits taken together are a 2 digit prime number. find the sum of these 2 prime

    asked by alya on October 6, 2011
  2. math

    Can someone help me with prime and composite numbers? Prime numbers are counting numbers that can be divided evenly bt only two numbers:1 and themselves. A prime number can also be described as a counting number with exactly two

    asked by haylo on October 24, 2006
  3. math

    what is the factorial of a negative number? The factorial function has singularities at the negative integers. You can see this as follows. For integers we define: (n+1)! = (n+1)n! and we put 0! = 1 So, from 0! you can compute 1!

    asked by chris on July 10, 2007
  4. MATH

    WRITE A SIMPLE BUT A COMPLETE FORTRAN PROGRAM TO COMPUTE THE AVERAGE OF SIX NUMBERS AND DISPLAY THE NUMBERS, SUM AND AVVERAGE. THE PROGRAM SHOULD TERMINATE WHEN ZERO IS ENTERED AS A NUMBER. THE PROGRAM SHOULD BE EDUCATIVE

    asked by EDWIN on June 15, 2011
  5. Math

    A positive integer n is defined as a "prime interlude" if n-1 and n+1 are both prime numbers. Which of the following is not a "prime interlude?" a.4 b.18 c.30 d.72 e.90 ( First of all; What is a "prime interlude??") I don't

    asked by Mack on August 9, 2007
  6. Math

    1. Set I contains six consecutive integers. Set J contains all integers that result from adding 3 to each of the integers in set I and also contains all integers that result from subtracting 3 from each of the integers in set I.

    asked by Irene on September 12, 2016

You can view more similar questions or ask a new question.