Exemplo n.º 1
0
def allPerm(num1, num2, num3):
    num1L = int2list(num1)
    num2L = int2list(num2)
    num3L = int2list(num3)
    num1L.sort()
    num2L.sort()
    num3L.sort()
    allPerms = False
    if(num1L == num2L and num1L == num3L):
        allPerms = True
    else:
        allPerms = False

    return allPerms
Exemplo n.º 2
0
        return [1, div]
    else:
        [newNum, newDen] = recSq(depth, divList)
        thisDen = div*newDen + newNum
        thisNum = newDen
        # print(str(depth) + " a  " + str(thisNum) + "/" + str(thisDen))
        return [thisNum, thisDen]


divList = []
thisEven = 2
while len(divList) <= 100:
    divList.append(1)
    divList.append(thisEven)
    divList.append(1)
    thisEven += 2

divList = divList[0:99]

[n, d] = recSqEntry(0, divList)

print(n)
print(d)

numList = int2list(n)

thisSum = sum(numList)

print(n / d)
print(thisSum)
Exemplo n.º 3
0
    finalDen = den
    return [finalNum, finalDen]


def recSq(iterations):
    iterations -= 1
    if iterations <= 0:
        return [1, 2]
    else:
        [newNum, newDen] = recSq(iterations)
        thisDen = 2 * newDen + newNum
        thisNum = newDen
        return [thisNum, thisDen]


sys.setrecursionlimit(10000)

n = 0
d = 0
count = 0
for i in range(1, 1001):
    [n, d] = recSqEntry(i)
    nList = int2list(n)
    dList = int2list(d)
    if len(nList) > len(dList):
        count += 1
        # print(str(i) + "   " + str(n) + "/" + str(d) + "     " + str(count))


print(count)
Exemplo n.º 4
0
from black_box import ispalindrome
from black_box import int2list
from black_box import list2int


foundNum = 0


for num in range(1, 10000):
    # print(num)
    found = False
    number = num
    for iterations in range(0,50):
        numList = []
        numList = int2list(number)
        numList.reverse()
        numRev = list2int(numList)

        number = number + numRev

        if(ispalindrome(int2list(number))):
            # print(num)
            # print(iterations)
            # print(number)
            found = True
            foundNum += 1
            break

print(9999-foundNum)
Exemplo n.º 5
0
        print(num)
        print(len(oneList))
        print(len(otherList))

    if num in oneList:
        continue
    elif num in otherList:
        continue


    found = False
    thisList = [num]
    numSum = num
    while not found:
        # print(thisList[-1])
        numList = int2list(numSum)
        numSum = sum([pow(i,2) for i in numList])
        # print(numSum)
        if numSum in oneList:
            for n in thisList:
                oneList.append(n)
                found = True
        elif numSum in otherList:
            for n in thisList:
                otherList.append(n)
                found = True
                if(n < endNum):
                    count += 1
        else:
            # print("Append")
            thisList.append(numSum)
Exemplo n.º 6
0
# A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is 
# almost unimaginably large: one followed by two-hundred zeros. Despite their size, the 
# sum of the digits in each number is only 1.

# Considering natural numbers of the form, a^b, where a, b < 100, what is the maximum 
# digital sum?


from black_box import int2list
from black_box import list2int
from math import pow

#had to do my own power function because it keeps the integer in long format
#instead of scientific notation
def myPower(aa, bb):
    myPowerValue = 1
    for i in range(1, bb+1):
        myPowerValue *= aa
    return myPowerValue


maxSum = 0
for a in range(1, 100):
    for b in range(1,100):
        num = myPower(a,b)
        numList = int2list(int(num))
        numListSum = sum(numList)
        if(numListSum > maxSum):
            maxSum = numListSum

print(maxSum)