Tina's brother gave her a friendly task of calculating the number of squares in a board that has n*n squares of dimensions 1cm *1cm each.
#include <stdio.h>
int main(){
int n;int j;
scanf("%d",&n);
j=(n*(n+1)*((2*n)+1))/6;
printf("%d",j);
return 0;}
int main(){
int n;int j;
scanf("%d",&n);
j=(n*(n+1)*((2*n)+1))/6;
printf("%d",j);
return 0;}
Comments
Post a Comment