This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime(n): | |
primes = [2] | |
for k in range(1, n): | |
i = primes[k - 1] | |
isPrime = False | |
while not isPrime: | |
i += 1 | |
isPrime = True | |
for p in primes: | |
if i % p == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime(n): | |
primes = [2] | |
for k in range(1, n): | |
i = primes[k - 1] | |
isPrime = False | |
while not isPrime: | |
i += 1 | |
isPrime = True | |
for p in primes: | |
if p * p > i: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
#include <math.h> | |
int prime(int n) | |
{ | |
int primes[10001] = {2}, p; | |
for (int k = 1; k < n; k++) { | |
int i = primes[k - 1]; | |
bool isPrime = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = "73167176531330624919225119674426574742355349194934\ | |
96983520312774506326239578318016984801869478851843\ | |
85861560789112949495459501737958331952853208805511\ | |
12540698747158523863050715693290963295227443043557\ | |
66896648950445244523161731856403098711121722383113\ | |
62229893423380308135336276614282806444486645238749\ | |
30358907296290491560440772390713810515859307960866\ | |
70172427121883998797908792274921901699720888093776\ | |
65727333001053367881220235421809751254540594752243\ | |
52584907711670556013604839586446706324415722155397\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 0 | |
while True: | |
a += 1 | |
if 1000 * (500 - a) % (1000 - a) == 0: | |
break | |
b = 1000 * (500 - a) // (1000 - a) | |
c = 1000 - a - b | |
print(a * b * c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k = 0 | |
i = 2 | |
primes = [] | |
while i < 2000000: | |
primes.append(i) | |
k += 1 | |
i = primes[k - 1] | |
isPrime = False | |
while not isPrime: | |
i += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
int main() | |
{ | |
int k = 0, i = 2, primes[1000000] = {}, p; | |
long long sum = 0; | |
while (i < 2000000) { | |
sum += (primes[k++] = i); | |
i = primes[k - 1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('pe011.in', 'r') | |
m = [] | |
max_r = 0 | |
for line in f: | |
m.append(line.split()) | |
for i in range(len(m)): | |
for j in range(len(m[0])): | |
m[i][j] = int(m[i][j]) | |
for i in range(len(m)): | |
for j in range(len(m[0])): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 0 | |
s = 1 | |
while s <= 500: | |
n += 1 | |
t = m = (n + 1) * n // 2 | |
s = 1 | |
p = 2 | |
counter = 0 | |
while t % p == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int n = 0, s = 1, m, t; | |
while (s <= 500) { | |
n++; | |
t = m = (n + 1) * n / 2; | |
s = 1; | |