HackerRank - The Trigonometric Ratios (Cold Golf)

I tried Python:

def f(x,i,n,a,b,r,s,w):
    if(i>n):return r
    return f(x,i+1,n,a*x*x,b*2*i*(2*i+s),r+a*w/b,s,-w)
n=int(input())
for _ in range(n):
    v=float(input())    
    print(("%.3f"%f(v,1,5,v,1,0,1,1)).rstrip(0))    
    print(("%.3f"%f(v,1,5,1,1,0,-1,1)).rstrip(0))

Looks like 1st on leatherboard is in Ruby.. ok, will try it next time.

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。