Project Euler #28: Number spiral diagonals

  • + 0 comments
    def sum_of_spiral_diagonal(n):
        s = (16*(n**3)+30*(n**2)+26*n+ 3)//3
        return s % (10**9+7)
    
    # Read the number of test cases
    t = int(input())
    
    # Iterate over the test cases
    for i in range(t):
        # Read the input and divide it by 2
        n = int(input()) // 2 # this indicates the spiral number
        print(sum_of_spiral_diagonal(n))