#Perl, <s>120</s> <s>108</s> <s>104</s> 89 <>=~/ /;$c=$t=1;for(1..2*$'-1){$t*=$`/$_;$_%2?$s:$c+=$t*(1-($_&2))}printf"%.8f\n"x2,$s,$c Ungolfed: <>=~/ /; $c=$t=1; for(1..2*$'-1){ $t*=$`/$_; $_%2? $s : $c += $t*(1-($_&2)) } printf"%.8f\n"x2,$s,$c Basically loops from 1 to `n`, and updates `$t` to be equal `x^$_/$_!` (`$_` is the loop index). It then decides whether to add it to the sine or cosine depending on whether `$_` is odd or even. Whether each term needs to be added or subtracted is decided by the magic formula `(1-($_&2))` (that's 1 minus the index-bitwise-and-2).