全部博文(43)
发布时间:2013-01-03 16:04:07
Problem description:When we calculate for prime numbers with a sieve method,we delete so many numbers which is not necessary repeatly.For instance,there is a number which consists of 3x7x17x23,and we delete it when we delete the multiples of 3 as we delete the same number when we delete the multiple......【阅读全文】
发布时间:2013-01-03 12:03:54
Problem description:Calculate the prime numbers with a sieve method.There is a magical sieve that can remove all the multiple of the number i.Please calculate the prime numbers at a range from 2 to N by this way.There is a requirement that you should not use multiplication and division.You can ......【阅读全文】
发布时间:2013-01-02 21:07:29
问题描述:在做筛法求质数的问题时,在删除非质数的数据时,有很多是重复删除的。例如,如果有一个数是3x7x17x23,那么在删除3的倍数时会删除它,删除7,17与23的倍数时也都会删除它。请写一个程序,在删除非质数时"绝对"不做重复的工作。 思路:有一个因式分解定理:任何一个合数都可以分解成若干个质数相乘的形式。那么,num一定可以分解成p的i次方乘以q的形式(p,q是质数且p<q)。所以,需要去除的数就变成了p的2次方,p的3次方,p的4次方......以......【阅读全文】