您的位置:首页 > 其它

<什么是数学>第一章习题

2011-05-02 17:40 323 查看
1.用以a=2,3,...,15为底,给0到1000的数字起名字,需要多少个不同的数字的名称?哪一种基底要求的数字名称最少?

写了个小程序来测试,答案是4,需要8个数字名称.

#include <stdio.h>
#define START_BASE 2
#define BASE_LIMIT 16
#define NUMBER 1001

int main(void)
{
int min_number_base = START_BASE;
int min_number_count = NUMBER;

int base;
int count;
int product;
for(base=START_BASE; base < BASE_LIMIT; base++)
{
count = base;
product = 1;
while((product *= base) < NUMBER)
{
count++;
}
if (count < min_number_count)
{
min_number_base = base;
min_number_count = count;
}
printf("base:%d\n",base);
}

printf("The min number of base is: %d\n",min_number_base);
printf("The count is: %d\n",min_number_count);

待续.......
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: