We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#define max 10000intmain(){intt;scanf("%d",&t);intarr[max];for(inta0=0;a0<t;a0++){scanf("%d",&arr[a0]);}for(inta=0;a<t;a++){intn=arr[a];ints1=n*(n+1)*(2*n+1)/6;ints2=n*n*(n+1)*(n+1)/4;ints=s2-s1;printf("%d\n",s);}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #6: Sum square difference
You are viewing a single comment's thread. Return to all comments →