File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ # Examen Parcial 1 Algoritmos y Estructuras 2 Seccion 305C1
2+
3+ # ----- Programacion Modular -----
4+
5+ def factorial (numero ):
6+ fact = 1
7+ for i in range (1 , numero + 1 ):
8+ fact *= i
9+ return (fact )
10+
11+ def coseno (num , termino ):
12+ bandera = True
13+ result = 1
14+
15+ if (termino % 2 == 0 ):
16+ for i in range (2 , termino + 2 , 2 ):
17+ if (bandera ):
18+ result -= pow (num , i ) / factorial (i )
19+ bandera = False
20+ else :
21+ result += pow (num , i ) / factorial (i )
22+ bandera = True
23+
24+ if ((termino % 2 == 1 ) & (termino > 1 )):
25+ for i in range (2 , termino + 2 , 2 ):
26+ if (bandera ):
27+ result -= pow (num , i ) / factorial (i )
28+ bandera = False
29+ else :
30+ result += pow (num , i ) / factorial (i )
31+ bandera = True
32+
33+ print ('El valor de termino' ,termino ,'es:' , result )
34+
35+
36+
37+ num1 = int (input ('Ingrese un termino de la serie: ' ))
38+ numF = int (input ('Coseno de: ' ))
39+ """
40+ num2 = int(input('Ingrese la aproximacion de la serie hasta un n dado: '))
41+ num3 = int(input('Ingrese la toleracia hasta donde llegara la serie: ')) """
42+
43+ coseno (numF , num1 )
You can’t perform that action at this time.
0 commit comments