Vous êtes sur la page 1sur 7

WIWI&DATA

PROGRAMAS EN FORTRAN 90 - I

1.- Este programa permite sumar los primeros 200 numeros de una sucesión de
números enteros.
Program suma_p_numeros
Integer::p,s,a
Print*,”****************”
Print*,”suma de p términos consecutivos” }
Print*,”de una sucesión de números reales”
Print*,”****************”
Print*,”cuantos términos de la sucesión desea sumar”
Read*,p
Print*,”índice de termino an, suma sn”
Read*,n,a,s
Do n=1 p,1
S=s+a
Print*”n,an,sn”
En do
Do
Nn+1
End do
End program suma_p_numeros

2.- Este programa sirve para formar los términos de una sucesión de números
reales.
En la línea 160 se indica los términos de se desean formar, también se podría
formarlos de 10 en 10. En la línea 170 se escribe la expresión del termino general
de la sucesión.
CODIGO DEL PROGRAMA EN FORTRAM 90
program problema_sucesion
real::an
integer::p,n
print*,"sucesion de numeros reales"
print*,"formacion de terminos de una sucesion"
print*,"*************************************"
print*,"cuantos terminos desea formar"
read*,p
print*,"indice", "termino"
print*,"******", "*******"
do n=1,p
an=(3.*n)/((n**2)+1)
print*,"n=",n,"a",n,an
end do
end program problema_sucesion
WIWI&DATA

3.- Sucesiones del número e


Este breve programa es un caso particular del programa anterior, sirve para formar
términos de la sucesión de números reales que tiene por limites el numero e
Solución:
PROGRAM SUCESIONES_DEL_NUMERO_e
INTEGER:: N
REAL:: A,AN
PRINT*, "SUCESIONES DE NUMEROS REALES"
PRINT*, "FORMACION DE TERMINOS DE LA SUCESION DEL NUMERO e"
PRINT*, "CUANTOS TERMINOS DESEA FORMAR"
READ*,AN
PRINT*, "INDICE TERMINO"
READ*, A,N
DO N=1, AN,1
AN=(1.+1/N)**N
PRINT*, "N=",N,"A",N,AN
END DO
END PROGRAM SUCESIONES_DEL_NUMERO_e

4.- OPERACIONES CON NUMEROS COMPLEJOS EN FORMA BINOMICA


program tarea
complex::suma,resta,multi,divi
complex::z1
complex::z2
print*,"ingrese complejo z1"
print*,"ingrese complejo z2"
read*,z1,z2
suma=z1+z2
print*,"la suma de los complejos es ",suma
resta=z1-z2
print*,"la resta de los complejos es ",resta
multi=z1*z2
print*,"la multiplicacion de los complejos es ",multi
divi=z1/z2
print*,"la division de los complejos es ",divi
end program tarea

5.- El presente programa sirve para calcular las anualidades de capitalización que
son unas cantidades fijas que se pagan al principio de cada año para formar junto
con sus intereses (compuesto) un capital al cabo de un cierto número de años.
El programa permite calcular las siguientes opciones:
La anualidad de capitalización A
El capital C formado al cabo de T años
El número de años T.
La expresión que nos da el capital final formado es la siguiente:
WIWI&DATA

A(1 + R)((1 + R)T − 1)


C=
R

De esta expresión se deducen las demás para efectuar los cálculos de las otras
opciones.
CÓDIGO DEL PROGRAMA EN FORTRAN 90
program capitalizacion
integer::opcion,T
real::C,R,A,X
character(len=1)::otro="s"
do while(otro=="s" .or. otro=="S")
print*,"**********************************************************"
print*
print*,"ANUALIDADES DE CAPITALIZACION"
print*
print*,"**********************************************************"
print*
print*,"Este programa le permite calcular:"
print*
print*,"1. La anualidad de capitalizacion"
print*,"2. El capital formado en T annos"
print*,"3. El numero de annos"
print*
print*,"Segun la opcion deseada pulse el numero que le precede"
read*,opcion
if(opcion==1) then
print*,"CALCULO DE LA ANUALIDAD DE CAPITALIZACION"
print*
print*,"CAPITAL QUE SE DESEA FORMAR C="
READ*,C
PRINT*,"TANTO POR CIENTO ANUAL R="
READ*,R
PRINT*,"NUMERO DE ANNOS T="
READ*,T
A=(C*R/100.)/((1+R/100.)*(1+R/100.)**(T-1))
PRINT*,"LA ANUALIDAD NECESARIA PARA FORMAR EL CAPITAL ",C,"
ES=", A
ELSE
IF(OPCION==2) THEN
PRINT*,"CALCULO DEL CAPITAL FORMADO AL CABO DE T
ANNOS"
PRINT*,"ANUALIDAD DE CAPITALIZACION A="
READ*,A
PRINT*,"TANTO POR CIENTO ANUAL R="
READ*,R
PRINT*,"NUMERO DE ANNOS T="
READ*,T
WIWI&DATA

C=A*(1+R/100.)*((1+R/100.)**(T-1))*100/R
PRINT*,"EL CAPITAL FORMADO AL CABO DE ",T," ANNOS ES=",C
ELSE
IF(OPCION==3)THEN
PRINT*,"CALCULO DE NUMERO DE ANNOS"
PRINT*,"ANUALIDAD A PAGAR A="
READ*,A
PRINT*,"CAPITAL FORMADO AL CABO DE T ANNOS C="
READ*,C
PRINT*,"TANTO POR CIENTO ANUAL R="
READ*,R
X=(C*R/100.)/(A*(1+R/100.))
T=LOG10(1+X)/LOG10(1+R/100.)
PRINT*,"EL NUMERO DE ANNOS ES=", T
END IF
END IF
END IF
PRINT*,"REALIZAR OTRO CALCULO S/N"
READ*,otro
END DO
end program capitalizacion

7.- Sucesiones geometricas


PROGRAM SUCESION_GEOMETRICA
REAL::N,P,A,A1,M,R,H,U,T,Y,C
PRINT*, "SUCECIONES GEOMETRICAS"
PRINT* "======================"
PRINT*, "EL PRESENTE PROGRAMA LE PERMITE CALCULAR LO SIGUIENTE"
PRINT*
PRINT*,"1.-CALCULO DEL TERMINO N-ESIMO"
PRINT*,"2.-CALCULO DE LA RAZON"
PRINT*,"3.-CALCULO DEL TERMNO PRIMERO"
PRINT*,"4.-CALCULO DEL NUMERO DE TERMINOS"
PRINT*,"5.-INTERPOLAR H MEDIOS DEOMETRICOS ENTRE DOS NUMEROS
DADOS"
PRINT*,"6.-CALCULO DE LA SUMA DE N TERMINOS CONSECUTIVOS
ABS(R)>=1"
PRINT*,"7.-CALCULO DE LA SUMA DE LOS INFINITOS TERMINOS (-1<R<1)"
PRINT*,"8.-CALCULO DEL PRODUCTO DE N TERMINOS CONSECUTIVOS"
PRINT*, "SEGUN LA OPCION DESEADA PULSE EL NUMERO QUE PRECEDE"
READ*, P
PRINT*,"CALCULO DEL TERMINO N-ESIMO"
PRINT*,"TERMINO PRIMERO ="
READ*, A1
PRINT*,"NUMERO DE TERMINOS N ="
READ*, N
PRINT*,"RAZON ="
WIWI&DATA

READ*, R
DO
A=A1*R**(N-1)
END DO
PRINT*,"EL TERMINO N-ESIMO ="
PRINT*,"CALCULO DE LA RAZON"
PRINT*,"TERMINO PRIMER A1 ="
READ*, A1
PRINT*, "TERMINO N-ESIMO AN = "
READ*, AN
PRINT*, " NUEKMRO DE TERMINOS N = "
READ*, N
DO
R=(AN/AN)**(1/(N-19))
PRINT*,"LA RAZON O DIFERENCIA DE LA PROGRESION ES R = ", R
END DO
PRINT*,"CALCULO DEL TERMINO PRIMERO"
PRINT*,"RAZON = "
READ*, R
PRINT*, "TERMINO N-ESIMO AN = "
READ*, AN
PRINT*, " NUMERO DE TERMINOS = "
READ*, N
DO
A1=AN/(R**(N-1))
PRINT*,"PRIMER TERMINO DE PROGRESION A1 =", A1
END DO
PRINT*,"CALCULO DEL NUMERO DE TERMINOS"
PRINT*,"RAZON = "
READ*, R
PRINT*, "TERMINO N-ESIMO AN = "
READ*, AN
PRINT*, " TERMINO PRIMERO A1 = "
READ*, A1
DO
N=1+(LOG(AN)-LOG(A1))/LOG(R)
PRINT*,"EL NUMERO DE TERMINOS N = ", N
END DO
PRINT*,"INTERPOLAR H MEDIOS GEOMETRICOS ENTRE DOS TERMINOS
DADOS"
PRINT*,"CUANTOS TERMINOS DESEA INTERPOLAR H = "
READ*, H
PRINT*, "INTRODUSCA EL PRIMERO Y EL ULTIMO TERMINO ENTRE LOS
QUE QUIERE INTERPOLAR";H; "MEDIOS GEOMETRICOS"
READ*, P,U
DO
R=(U/P)**(1/(H+1))
WIWI&DATA

PRINT*," LA RAZON DE LA PROGRESION ES R =" , R


PRINT*," LOS MEDIOS GEOMETRICOS INTERPOLADOS SON = "
DO I=1, H , 1
T=P*R**I
PRINT*, T
END DO
END PROGRAM SUCESION_GEOMETRICA

8.- Sucesiones en fortran


Program sucesiones
real::d
integer::H,P,U,AN,A1,CS,N
character(LEN=1)::otro="s"
Do while(otro=="s".or.otro =="S")
print*,"PROGRESIONES ARITMETICAS"
print*,"========================="
print*
print*,"1.CALCULO DE LA RAZON"
print*,"2.CALCULO LA SUMA DE N TERMINOS CONSECUTIVOS"
print*,"3.CALCULO DEL TERMINO N ÈSIMO"
print*,"4.CALCULO DEL PRIMER TERMINO"
print*,"5.INTERPOLAR H MEDIOS ARITMETICOS"
print*
print*,"<<SELECCIONE UNA OPCION>>"
read*,opcion
IF (opcion==1) then
print*,"CALCULO DE LA RAZON"
print*,"Ingrese el primer termino"
read*,A1
print*,"Ingrese el termino N esimo"
read*,An
print*,"Ingrese el numero de terminos"
read*,N
D=(AN-A1)/(N-1)
print*,"La razon es:",d
else
IF (opcion==2) then
print*,"CALCULO SUMA DE TERMINOS CONSECUTIVOS"
print*,"Ingrese el primer termino"
read*,A1
print*,"Ingrese la razon"
read*,d
print*,"Ingrese el numero de terminos"
read*,N
CS=n*(a1+(n-1)*(d/2))
print*,"La razon es:",cs
else
WIWI&DATA

IF (opcion==3) then
print*,"CALCULO DEL TERMINO N ÈSIMO"
print*,"Ingrese el primer termino"
read*,a1
print*,"ingrese el numero de terminos"
read*,n
print*,"ingrese la razon"
read*,d
an=a1+(n-1)*d
print*,"El termino N esimo es:",an
else
IF (opcion==4) then
print*,"CALCULO DEL PRIMER TERMINO"
print*,"Ingrese el numero de terminos"
read*,n
print*,"Ingrese la razon"
read*,d
print*,"Ingrese el termino N esimo"
read*,an
a1=an-(n-1)*d
print*,"El primer termino es:",a1
else
IF (opcion==5) then
print*,"INTERPOLAR H MEDIOS ARITMETICOS ENTRE DOS TERMINOS
DADOS"
print*,"Cuantos medios desea interpolar"
read*,H
print*,"Introduzca el primero y el ultimo termino entre los que quiere interpolar"
read*,p,u
d=(u-p)/(h+1)
print*
print*,"La razon de la progresion es:",d
print*,"Los medios aritmeticos interpolados son:"
do i=1,h
t=p+i*d
print*,T
end do
end if
end if
end if
end if
end if
print*,"realizar otro calculo S/N"
read*,otro
end do
end program

Vous aimerez peut-être aussi