-
Lenguaje
Pascal
-
Descripción
Obtener el seno de un ángulo, la cual está dada por la función:
Sen x = (x - x³/3! + x⁵5/5! - x⁷/7! + ...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
program SerieParaObtenerSeno;
uses crt, math;
var i, n : integer;
var exponente, factorial, sen_x, termino, x : real;
begin
sen_x := 0;
write ('Ingresa el valor de x: ');
readln (x);
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
if i=1 then
begin
exponente := 1;
factorial := x;
termino := x;
end
else
begin
exponente := exponente+2;
factorial := factorial*x*x;
termino := power(x,exponente)/factorial;
end;
if i mod 2=0 then
begin
sen_x := sen_x-termino;
end
else
begin
sen_x := sen_x+termino;
end;
writeln ('Valor de exponente: ', exponente:0:6);
writeln ('Valor de factorial: ', factorial:0:6);
writeln ('Valor de termino: ', termino:0:6);
writeln;
end;
writeln ('Valor de sen x: ', sen_x:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt, math;
var i, n : integer;
var exponente, factorial, sen_x, termino, x : real;
begin
sen_x := 0;
write ('Ingresa el valor de x: ');
readln (x);
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
if i=1 then
begin
exponente := 1;
factorial := x;
termino := x;
end
else
begin
exponente := exponente+2;
factorial := factorial*x*x;
termino := power(x,exponente)/factorial;
end;
if i mod 2=0 then
begin
sen_x := sen_x-termino;
end
else
begin
sen_x := sen_x+termino;
end;
writeln ('Valor de exponente: ', exponente:0:6);
writeln ('Valor de factorial: ', factorial:0:6);
writeln ('Valor de termino: ', termino:0:6);
writeln;
end;
writeln ('Valor de sen x: ', sen_x:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.