Skip to content

Instantly share code, notes, and snippets.

@ebartrum
ebartrum / Euler 33
Last active August 29, 2015 14:12
A solution to the 33rd Project Euler problem
#Define a function to return true if we have a digit cancelling fraction
"""The function will take 2 inputs: [a,b],[c,d].
It will return true if ab/cd is a digit cancelling fraction."""
#Define a function to return a common element of x,y
def commonElt(x,y):
for z in x:
if z in y:
@ebartrum
ebartrum / gist:cba4fe5cebec90f85380
Last active August 29, 2015 14:12
463 in progress
#Define the function f by recursion:
def f(n):
if n==1:
return 1
if n==3:
return 3
if n%2==0:
return f(n/2)
if (n-1)%4==0:
m=(n-1)/4