Quadratic primes
Problem 27
Euler discovered the remarkable quadratic formula:
n² + n + 41
It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. Howe...
分类:
编程语言 时间:
2015-06-17 21:37:46
阅读次数:
149
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest s...
分类:
其他好文 时间:
2015-06-07 17:35:13
阅读次数:
129
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
本文是在学习中的总结,欢迎转载但请注明出处: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
又水,素数只能是连续的,而且最多才10000! 1 #include 2 3 using namespace std; 4 5 int a[10001]; 6 7 bool is_prime(int x) 8 { 9 if(x == 1) return 0;10 for...
分类:
其他好文 时间:
2015-06-02 21:25:09
阅读次数:
122
Euler discovered the remarkable quadratic formula:
n² + n + 41
It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40...
分类:
其他好文 时间:
2015-06-02 11:16:49
阅读次数:
139
I guess the punch line of this one is Sieving for primes.#include #include #include #include #include #include #include #include using namespace std;v...
分类:
其他好文 时间:
2015-05-28 02:01:14
阅读次数:
414
题目如下:
A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is al...
分类:
其他好文 时间:
2015-05-25 14:39:05
阅读次数:
140
leetcode Count Primes 204
Sieve of Eratoasthenes...
分类:
其他好文 时间:
2015-05-21 10:52:07
阅读次数:
123
Count the number of prime numbers less than a non-negative number,n思路:数质数的个数开始写了个蛮力的,存储已有质数,判断新数字是否可以整除已有质数。然后妥妥的超时了(⊙v⊙)。看提示,发现有个Eratosthenes算法找质数的,说...
分类:
其他好文 时间:
2015-05-21 10:47:58
阅读次数:
110