diff options
Diffstat (limited to 'wip')
| -rw-r--r-- | wip/023-non_abudant_sums.py | 16 | ||||
| -rw-r--r-- | wip/026-reciprocal_cycles.py | 5 | ||||
| -rw-r--r-- | wip/027-quadratic_primes.py | 17 | ||||
| -rw-r--r-- | wip/031-coin_sums.py | 12 | ||||
| -rw-r--r-- | wip/037-truncatable_primes.py | 25 | ||||
| -rw-r--r-- | wip/045-triangular_pentagonal_and_hexagonal.py | 9 | ||||
| -rw-r--r-- | wip/047-distinct_primes_factors.py | 20 | ||||
| -rw-r--r-- | wip/049-prime_permutations.py | 23 | ||||
| -rw-r--r-- | wip/053-combinatoric-selections.c | 43 | ||||
| -rw-r--r-- | wip/092-square_digit_chains.c | 89 |
10 files changed, 0 insertions, 259 deletions
diff --git a/wip/023-non_abudant_sums.py b/wip/023-non_abudant_sums.py deleted file mode 100644 index 6e3eea2..0000000 --- a/wip/023-non_abudant_sums.py +++ /dev/null @@ -1,16 +0,0 @@ -# def getAllDivisorOf(num): -# divisor_list = [] -# for i in range(1, num): -# if num % i == 0: -# divisor_list.append(i) -# return divisor_list - - -# for num in range(1, 28123 + 1): -# pass - -# for i in range(3): -# for j in range(3): -# for k in range(3): -# if i != j and i != k and j != k: -# print(i, j, k) diff --git a/wip/026-reciprocal_cycles.py b/wip/026-reciprocal_cycles.py deleted file mode 100644 index b502c9a..0000000 --- a/wip/026-reciprocal_cycles.py +++ /dev/null @@ -1,5 +0,0 @@ -from decimal import Decimal - -for i in range(1, 11): - # decimals = int(str(1/i)[2:]) - print(d) diff --git a/wip/027-quadratic_primes.py b/wip/027-quadratic_primes.py deleted file mode 100644 index 8b21cc6..0000000 --- a/wip/027-quadratic_primes.py +++ /dev/null @@ -1,17 +0,0 @@ -from itertools import count -from helper.prime import is_prime - - -ab_iter = [(a, b) for b in range(1_001) for a in range(1_000)] - -max_product = 0 -max_prime_seq = 0 -for a, b in ab_iter: - for n in count(): - if (not is_prime(n**2 + a*n + b)) and n > max_prime_seq: - max_prime_seq = n - max_product = a * b - print(max_product) - break - - diff --git a/wip/031-coin_sums.py b/wip/031-coin_sums.py deleted file mode 100644 index c9a823d..0000000 --- a/wip/031-coin_sums.py +++ /dev/null @@ -1,12 +0,0 @@ -coins = [200, 100, 50, 20, 10, 5, 2, 1] - -TOTAL = 200 -coin_index = 0 -combinations = [200] -combination_nb = 1 -while True: - if sum(combinations) == 200: - coin_index += 1 - combinations[0] = coins[coin_index] - - diff --git a/wip/037-truncatable_primes.py b/wip/037-truncatable_primes.py deleted file mode 100644 index 1ad7d29..0000000 --- a/wip/037-truncatable_primes.py +++ /dev/null @@ -1,25 +0,0 @@ -from helper.prime import primes_loop, is_prime - - -def is_truncatable(prime): - p_str = str(prime) - for i in range(1, len(p_str)): - if not is_prime(int(p_str[i:])): - return False - for i in range(1, len(p_str)): - if not is_prime(int(p_str[:-i])): - return False - if prime in [2, 3, 5, 7]: - return False - return True - - -trunc_p_list = [] -for p in primes_loop(): - if is_truncatable(p): - trunc_p_list.append(p) - if len(trunc_p_list) == 11: - break - -print(trunc_p_list) -print(sum(trunc_p_list)) diff --git a/wip/045-triangular_pentagonal_and_hexagonal.py b/wip/045-triangular_pentagonal_and_hexagonal.py deleted file mode 100644 index 5fba8f8..0000000 --- a/wip/045-triangular_pentagonal_and_hexagonal.py +++ /dev/null @@ -1,9 +0,0 @@ -from itertools import count -from helper.numbers import triangular, is_pentagonal, is_hexagonal - - -for i in count(286): - t = triangular(i) - if is_pentagonal(t) and is_hexagonal(t): - print(t) - break diff --git a/wip/047-distinct_primes_factors.py b/wip/047-distinct_primes_factors.py deleted file mode 100644 index ac09b9a..0000000 --- a/wip/047-distinct_primes_factors.py +++ /dev/null @@ -1,20 +0,0 @@ -from itertools import count -from helper.prime import get_prime_factors, primes_loop - -# TROP LENT - -def as_four_distinct_prime_factors(num): - return len(set(get_prime_factors(num))) == 3 - -def check_next_three(num): - for i in range(1, 3): - if not as_four_distinct_prime_factors(num + i): - return False - return True - - -for num in primes_loop(): - if as_four_distinct_prime_factors(num): - if check_next_three(num): - print(num) - break diff --git a/wip/049-prime_permutations.py b/wip/049-prime_permutations.py deleted file mode 100644 index d90754e..0000000 --- a/wip/049-prime_permutations.py +++ /dev/null @@ -1,23 +0,0 @@ -from itertools import permutations -from helper.prime import is_prime - - -def constant_inscrease(perms): - - - -def get_prime_permutations(nb): - return sorted([ - int(''.join(x)) - for x in permutations(str(nb), 4) - if (is_prime(int(''.join(x))) - and len(str(int(''.join(x)))) == 4) - ]) - -# print(get_prime_permutations(1487)) -for i in range(1000, 10_000): - if not is_prime(i): - continue - print(get_prime_permutations(i)) -# if all([is_prime(p) for p in permutations]): -# print(sorted(permutations)) diff --git a/wip/053-combinatoric-selections.c b/wip/053-combinatoric-selections.c deleted file mode 100644 index 9006f5a..0000000 --- a/wip/053-combinatoric-selections.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - - -typedef long long unsigned int Natural; - -Natural factorial(Natural n) -{ - if (n == 1 || n == 0) return 1; - else return n * factorial(n - 1); -} - -Natural combination(Natural n, Natural r) -{ - if (r > n) exit(1); - Natural num = 0; - /* for (Natural i = 0; i < r - 1; i++) */ - /* num *= n - i; */ - /* return num / factorial(r); */ - /* if (factorial(r) * factorial(n - r) == 0) return 0; */ - return (factorial(n) / (factorial(r) * factorial(n - r))); - /* return (factorial(r) * factorial(n - r)); */ -} - -int main(void) -{ - printf("10! = %llu\n", factorial(10)); - printf("23! = %llu\n", factorial(23)); - printf("(23 - 10)! = %llu\n", factorial(23 - 10)); - int counter = 0; - Natural comb = 0, n, r; - /* for (n = 1; n <= 24; n++) */ - /* for (r = 1; r <= n; r++) { */ - /* comb = combination(n, r); */ - /* if (comb > 1000000) { */ - /* counter++; */ - /* comb = combination(23, 10); */ - printf("%llu C %llu = %llu\n", n, r, comb); - /* } */ - /* } */ - printf("counter = %d", counter); - return 0; -} diff --git a/wip/092-square_digit_chains.c b/wip/092-square_digit_chains.c deleted file mode 100644 index 7029ccd..0000000 --- a/wip/092-square_digit_chains.c +++ /dev/null @@ -1,89 +0,0 @@ -#include <stdio.h> -#include <stdbool.h> -#include <math.h> - - -int lenHelper(int x) -{ - if (x >= 10000000) return 8; - if (x >= 1000000) return 7; - if (x >= 100000) return 6; - if (x >= 10000) return 5; - if (x >= 1000) return 4; - if (x >= 100) return 3; - if (x >= 10) return 2; - return 1; -} - -int get_digit(int nb, int digit_index) -{ - if (digit_index == 1) - return nb % 10; - - return (int)(nb / pow(10.0, (double)(digit_index-1))) % 10; -} - -int next_iteration(int nb) -{ - int i, sum = 0; - for (i = 0; i < lenHelper(nb); i++) { - sum += pow(get_digit(nb, i), 2); - } - return sum; -} - -bool end_of_square_digit_chain_is_89(int nb) -{ - bool once = false; - int next_nb; - for (int i = 0; i < 10; i++) { - // printf("%d", next_nb); - next_nb = next_iteration(nb); - if (next_nb == 89 || next_nb == 1) { - if (once) { - return next_nb == 89 ? true : false; - } - once = true; - } - nb = next_nb; - } - return false; -} - - -int main(void) -{ - int i, counter = 0; - for (i = 1; i < 10000000; i++) { - // printf("%d\n", i); - if (end_of_square_digit_chain_is_89(i)) - counter++; - if (i % 1000000 == 0) - printf("%d\n", counter); - } - - printf("%d\n", counter); - - return 0; -} - - - -// def end_of_square_digit_chain_is_89(nb): -// once = False -// while True: -// next_nb = sum([int(x)**2 for x in str(nb)]) -// if next_nb == 89 or next_nb == 1: -// if once: -// return True if next_nb == 89 else False -// once = True -// nb = next_nb - -// counter = 0 -// for i in range(1, 10_000_000): -// if end_of_square_digit_chain_is_89(i): -// counter += 1 -// if i % 1000_000 == 0: -// print(counter) -// pass -// print(counter) |
