We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defcalculate_result(n):# Calculate the result using the given formulaw=n-1result=1+4*((n*(2*n+1)*(2*n-1))// 3 - 1) - 12 * ((w * (w + 1)) // 2)returnresult%(10**9+7)defmain():t=int(input(""))for_inrange(t):n=int(input())// 2 + 1result=calculate_result(n)print(result)if__name__=="__main__":main()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #28: Number spiral diagonals
You are viewing a single comment's thread. Return to all comments →