#include<stdio.h> #include<math.h> int main() { unsigned int sum; int n,a1, q; scanf_s("%d", &n); a1 = 1; q = 2; sum = a1*(1 - pow(q,n) )/ (1 - q); printf("n=:%d,sun=%u\n", n, sum); return 0; }
不能,n取64时,计算结果数据过大,超出无符号整形的范围