<?
y = 0.0
x = gets
x = x.to_f
def factorial(num)
return 1 if num==1
num * factorial(num-1)
end
0.upto(20) do |n|
y = y + ((-1)**n * x**(2*n + 1)) / factorial(2*n + 1)
print "(#{n}) \n Sum: #{y} \n Sine: #{Math.sin(x)} \n"
end
?>
|
|
|
|
Powered by: Trance Music & vBulletin Forums
|