fork download
  1. // 7
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. int n, i, pow;
  7.  
  8. printf("正の整数=");
  9. scanf("%d", &n);
  10.  
  11. i = 0;
  12. while (i <= n) {
  13. if (i == 0) {
  14. pow = 1;
  15. } else {
  16. pow *= 2;
  17. }
  18. printf("2^%d = %d\n", i, pow);
  19. i++;
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.02s 1680KB
stdin
30
stdout
正の整数=2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
2^10 = 1024
2^11 = 2048
2^12 = 4096
2^13 = 8192
2^14 = 16384
2^15 = 32768
2^16 = 65536
2^17 = 131072
2^18 = 262144
2^19 = 524288
2^20 = 1048576
2^21 = 2097152
2^22 = 4194304
2^23 = 8388608
2^24 = 16777216
2^25 = 33554432
2^26 = 67108864
2^27 = 134217728
2^28 = 268435456
2^29 = 536870912
2^30 = 1073741824