andy6804tw
7/16/2016 - 10:17 AM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=25957 古希臘數學家歐幾里得是通過2^{{n-1}}\times (2^{n}-1) 的表達式發現前四個完全數的。 當n=2:2^{1}\times

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=25957 古希臘數學家歐幾里得是通過2^{{n-1}}\times (2^{n}-1) 的表達式發現前四個完全數的。 當n=2:2^{1}\times (2^{2}-1)=6 當n=3:2^{2}\times (2^{3}-1)=28 當n=5:2^{4}\times (2^{5}-1)=496 當n=7:2^{6}\times (2^{7}-1)=8128 6(1位) 28(2位) 496(3位) 8128(4位) 33550336(8位) 8589869056(10位) 137438691328(12位) 2305843008139952128(19位) 2658455991569831744654692615953842176(37位) 191561942608236107294793378084303638130997321548169216(54位)

#include<stdio.h>  
int main()  
{  
    int arr[]={6,28,496,8128},i,a,b,count=0;  
    scanf("%d%d",&a,&b);  
    for(i=0;i<4;i++){  
        if(arr[i]>=a&&arr[i]<=b){  
            if(count>0)printf(" ");  
            printf("%d",arr[i]);  
            count++;  
        }  
    }  
    if(count==0)printf("null\n");  
    else printf("\n");  
    return 0;  
}