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
#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: |
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
#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 |
OlderNewer