Created
January 4, 2016 18:37
-
-
Save MattyAyOh/43377e074342cf059ae1 to your computer and use it in GitHub Desktop.
Single Digit to the Exponent of 100
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
# Write a method that takes a single integer and prints that integer to the power of 100 | |
firstNum = 3 | |
numArray = [firstNum] | |
for i in range(0,99): | |
previousCarry = 0 | |
lastValue = 0 | |
lengthOfArray = len(numArray) | |
for j in range(0,lengthOfArray): | |
newProduct = firstNum * numArray[j] + previousCarry | |
# print "newint " + str(newProduct) | |
previousCarry = newProduct/10 | |
# print "prevCarry " + str(previousCarry) | |
lastValue = newProduct%10 | |
# print "newValue " + str(lastValue) | |
numArray[j] = lastValue | |
# print "FinalArray: ", | |
# print numArray | |
if previousCarry > 0: | |
numArray.append(previousCarry) | |
reversedArray = numArray[::-1] | |
answerString = "" | |
for value in reversedArray: | |
answerString += str(value) | |
print answerString | |
arrayOfAnswers = [ | |
"0", | |
"1", | |
"1267650600228229401496703205376", | |
"515377520732011331036461129765621272702107522001", | |
"1606938044258990275541962092341162602522202993782792835301376", | |
"7888609052210118054117285652827862296732064351090230047702789306640625", | |
"653318623500070906096690267158057820537143710472954871543071966369497141477376", | |
"3234476509624757991344647769100216810857203198904625400933895331391691459636928060001", | |
"2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376", | |
"265613988875874769338781322035779626829233452653394495974574961739092490901302182994384699044001" | |
] | |
for value in arrayOfAnswers: | |
print value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment