This file contains hidden or 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 A(k,n): | |
total = 0 | |
f0 = 1 | |
modulo = 1000000007 | |
power = pow(2, n//k, modulo) | |
for a in range(0, n//k + 1): | |
total = (total + (f0 * pow(power, k-2*a, modulo))) % modulo | |
f0 = (f0*(k-2*a)*(k-2*a-1)) % modulo | |
f0 = (f0*pow((a+1)**2, -1, modulo)) % modulo | |
return total |
This file contains hidden or 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 compute(): | |
eulercoins = [1504170715041707] | |
current_eulercoin = 1504170715041707 | |
inv = pow(1504170715041707, -1, 4503599627370517) | |
n = 2 | |
while True: | |
number = 1504170715041707*n % 4503599627370517 #Search downwards | |
if number < current_eulercoin: | |
current_eulercoin = number | |
eulercoins.append(number) |
This file contains hidden or 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 compute(limit): | |
f = [int(4*(x**2)+1) for x in range(limit+1)] #Initialise the list f | |
max_prime_factor = [0]*(limit+1) #Initialise the list max_prime_factor | |
for x in range(1,len(f)): #Go through f | |
div = f[x] #Initialise divisor | |
if div > 1: #Check if divisor > 1 | |
curr1 = x % div | |
while curr1 <= limit: #while curr = x + k*f[x] < limit we continue | |
if f[curr1] % div == 0: #Check if f[x+k*f[x]] is divisible by f[x] | |
max_prime_factor[curr1] = max(max_prime_factor[curr1], div) |
This file contains hidden or 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 compute(): | |
count = [] | |
for n in range(1,10): | |
for i in range(1,22): | |
if i == len(str(n**i)): | |
count.append(n**i) | |
return len(count) | |
#Used the following function to find the bounds for n | |
#n = 9 bound is 22 because 9^22 |
This file contains hidden or 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 compute(cipher): | |
possiblecodes = [] | |
for x in range(97,123): | |
for y in range(97, 123): | |
for z in range(97,123): | |
password = chr(x) + chr(y) + chr(z) | |
count = 0 | |
decrypt = [] | |
for i in cipher: | |
temp = i^(ord(password[count % 3])) |
This file contains hidden or 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 compute(): | |
x = 100 | |
while True: | |
count = 1 | |
for i in range(2, 7): | |
if sorted(str(x)) != sorted(str(i*x)): | |
break | |
count += 1 | |
if count == 6: | |
return x |
This file contains hidden or 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 compute(): | |
primes = sorted(list(set(list_primes(10000)) - set((list_primes(1000))))) | |
supercandidates = [] | |
while len(primes) != 0: | |
curr = primes.pop() | |
candidates = [curr] | |
for y in primes: | |
if sorted(str(curr)) == sorted(str(y)): | |
candidates.append(y) |
This file contains hidden or 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 list_primality_modified(n): | |
result = [0] * (n + 1) #Initialize an array of length n+1 | |
for i in range(2,int((n)) + 1): #We want to go all the way to the length instead of sqrt(n) | |
#to include all prime factors | |
if result[i] == 0: #If this value has not been marked yet, continue | |
for j in range(2 * i, len(result), i): | |
result[j] += 1 #Add all the prime factors | |
return result | |
#We will obtain a list where array[x] represents the number of prime factors of x, | |
#if array[x] = 0 then x is a prime |
This file contains hidden or 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 goldbachs(number): | |
for x in range(1, int(math.sqrt(number))+1): | |
temp_var = number - 2*(x**2) | |
if is_prime(temp_var) == True: | |
return True | |
return False | |
def compute(): | |
count = 33 | |
while True: |
This file contains hidden or 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 all_numbers(alist): | |
nums = set() | |
for x in alist: | |
for y in x: | |
nums.add(y) | |
return list(nums) | |
def method1(): | |
possible_numbers = (all_numbers(keys)) | |
possible_passcode = list(itertools.permutations(possible_numbers)) |