home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
adaptor.zip
/
adapt.zip
/
adaptor
/
examples
/
fakul
/
fakul.f
next >
Wrap
Text File
|
1993-03-23
|
941b
|
42 lines
Program fakul
CC
CC Fakultaetsprogram, FORTRAN 90 Version
CC
integer max
integer feld(:), carry(:)
integer I,K,N
integer length
integer s, lastval
print *, 'Input value N !'
read *, N
print *, 'Input upper limit for size !'
read *, max
allocate (feld(1:max), carry(1:max))
feld = 0
carry = 0
feld(1)=1
length = 1
do K=N,1,-1
feld (1:length) = (feld(1:length) + carry(1:length)) * K
carry (1:length) = feld(1:length) / 65536
feld (1:length) = feld(1:length) - carry(1:length) * 65536
if (carry(length) .NE. 0) length = length + 1
carry = cshift (carry,1,-1)
end do
lastval = feld(length)
s = sum (feld (1:length))
deallocate (carry, feld)
print *, 'Size = ', length
print *, 'Lastval = ', lastval
print *, 'Control sum = ', s
end