#include <stdio.h>#include <math.h> main(){ int n,teste=1,base,i,aux; scanf("%d",&n); while(n != -1){ base = 2; aux = 1; for(i=1;i<=n;i++){ base += aux; aux *= 2; } printf("Teste %d\n",teste); //printf("%d\n\n",base*base); printf("%d\n\n",(int)(pow(4,n) + pow(2,n+1) + 1)); //dois \n para não dar erro de apresentação teste++; scanf("%d",&n); }}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -1
Teste 1 4 Teste 2 9 Teste 3 25 Teste 4 81 Teste 5 289 Teste 6 1089 Teste 7 4225 Teste 8 16641 Teste 9 66049 Teste 10 263169 Teste 11 1050625 Teste 12 4198401 Teste 13 16785409 Teste 14 67125249 Teste 15 268468225 Teste 16 1073807361
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!