-
-
Save peterssonjesper/3739539 to your computer and use it in GitHub Desktop.
Project Euler - Problem 28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define ROWS 1001 | |
int main() { | |
int levels; | |
int sum = 0; | |
int corner = 1; | |
int row_length = 2; | |
for(levels = 0; levels < ROWS/2; ++levels) { | |
sum += (2*corner + row_length*3)*2; | |
corner += 4*row_length; | |
row_length += 2; | |
} | |
sum += corner; | |
printf("The answer is %d\n", sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment