BUPT-homework/semester1/pset6/2-circle.c

23 lines
309 B
C

#include <stdio.h>
// Function prototypes
int calculate(int a);
int main(void) {
// Initialize variables
int n;
scanf("%i", &n);
// Calculate answer
printf("%i\n", calculate(n));
return 0;
}
int calculate(int a) {
if (a == 0) {
return 1;
} else {
return calculate(a - 1) - a + a * 2;
}
}