#K70602. Sum of Spiral Diagonals
Sum of Spiral Diagonals
Sum of Spiral Diagonals
You are given an odd integer n representing the dimensions of a square spiral. The spiral is created by starting with 1 at its center and moving to the right in a clockwise direction, filling the spiral in layers. Your task is to compute the sum of the numbers on both diagonals of this n × n spiral.
The pattern can be observed by noting that for each layer k (starting from k = 1 for the first outer layer), the step size is \(2k\). Each layer contributes 4 corner values, and the sum of these values (along with the center 1) gives the final result.
inputFormat
The input is a single integer n provided via standard input, which indicates the size of the spiral (an odd number).
outputFormat
The output is a single integer printed to standard output, representing the sum of the numbers on the diagonals of the spiral.
## sample1
1