码迷,mamicode.com
首页 >  
搜索关键字:prime    ( 2475个结果
Project Euler:Problem 46 Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×12 15 = 7 + 2×22 21 = 3 + 2×32 25 = 7 + 2×32 27 = 19 + 2...
分类:数据库   时间:2015-06-07 11:12:04    阅读次数:148
Project Euler:Problem 47 Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 × 7 15 = 3 × 5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2² × 7 × 23 ...
分类:其他好文   时间:2015-06-07 11:08:41    阅读次数:106
素数判断
1 #include "math.h"//判断素数的函数为了提高效率可能需要使用求平方根的库函数2 int prime (int num)//给定正整数,函数功能为判断其是否为素数3 {4 int qurt = sqrt((double)num);//求平方根函数参数为double,可使用强...
分类:其他好文   时间:2015-06-07 00:56:02    阅读次数:205
判断一个数是不是素数 埃拉托斯特尼筛法 时间复杂度 O(n*lglgn)
说明: 素数的定义:质数(prime number)又称素数。一个大于1的自然数,除了1和它本身外,不能被其他自然数整除,换句话说就是该数除了1和它本身以外不再有其他的因数;否则称为合数。 最小的素数是2,最小的合数是4 方法一: 根据素数的定义,判断数n是不是素数,我们只需要从i=2开始,判断n能不能被n整除,一直到n-1,如果可以则说明不是素数。另一方面,一个数若是合数,则一定...
分类:其他好文   时间:2015-06-05 10:27:32    阅读次数:789
Project Euler:Problem 41 Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandi...
分类:其他好文   时间:2015-06-05 10:11:25    阅读次数:111
Count prime
埃拉托斯特尼筛法wiki: http://zh.wikipedia.org/wiki/%E5%9F%83%E6%8B%89%E6%89%98%E6%96%AF%E7%89%B9%E5%B0%BC%E7%AD%9B%E6%B3%95步驟[编辑]详细列出算法如下:列出2以後的所有序列:2 3 4 5 6...
分类:其他好文   时间:2015-06-05 07:36:40    阅读次数:168
POJ1284---Primitive Roots(求原根个数, 欧拉函数)
Description We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is equal to { 1, …, p-1 }. For example, the consecutive power...
分类:其他好文   时间:2015-06-04 22:54:39    阅读次数:231
POJ2407---Relatives(求单个数的欧拉函数)
Description Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such t...
分类:其他好文   时间:2015-06-04 22:54:18    阅读次数:175
Lettcode_204_Count Primes
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/46366207 Description: Count the number of prime numbers less than a non-negative number, n. 思路: (1)题意为给定整数n,求解n以内的整数中有多少个素数(质数)。 (2)该题涉及到数学相关的知识。首先,看下素数的定义:质数(prime...
分类:其他好文   时间:2015-06-04 22:51:54    阅读次数:142
Project Euler:Problem 37 Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we c...
分类:其他好文   时间:2015-06-04 11:56:43    阅读次数:84
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!