I am trying to write a fortran program to take an integer n and print out the first n rows of Pascal's triangle. The code I have so far:(adsbygoogle = window.adsbygoogle || []).push({});

PROGRAM PascalTriangle

IMPLICIT NONE

INTEGER i, n, j, ktemp, ktemp1, ktemp2, ktemp3, ktemp4, ktemp5

WRITE(6,*), "Enter a positive integer n:> "

READ(5,*) n

do 10 i = 1, n

do 20 j = 1, i

ktemp1 = FACT(i)

ktemp2 = FACT(j)

ktemp3 = i - j

ktemp4 = FACT(ktemp3)

ktemp = ktemp1 / ktemp2 * ktemp4

write(*), ktemp

20 continue

10 continue

STOP

END

FUNCTION FACT(N)

FACT=1

DO 30 J=2,N

FACT=FACT*J

30 CONTINUE

RETURN

END

Whats really confusing me is that the compiler throws a single error at the ktemp1 = FACT(i) line, stating that its an invalid declaration of or reference to symbol FACT. It looks like it should be a simple fix but I can't seem to get around the error. Any help is greatly appreciated.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Simple fortran error

Loading...

Similar Threads - Simple fortran error | Date |
---|---|

Another simple fortran q | Sep 26, 2012 |

Simple fortran help | Sep 17, 2012 |

Help with a very simple fortran program. | Jan 22, 2012 |

Fortran Simple Harmonic Oscillator Problem | Dec 8, 2011 |

Simple program in Fortran, I get an error | Dec 22, 2009 |

**Physics Forums - The Fusion of Science and Community**