Some details, as said before, is that the length of the string grows exponential, which is just nearly as true as it does as a base_10 value; however, in base_10 format, I have been unable to predict the "exponential" rate of growth, so it appears to be a psuedo-random number than can be generated by an explicit function. And because it grows so fast, factorization of the key into its trivial parts quickly becomes more difficult and time consuming.
Let me know what you guys think. Code below is the functional program (currently set up for user input, but that can be subject to change as I might alter the function at a later time) as is and displays in the console/shell upon being imported.
#base 10 to base 2 converter
def DenaryToBinary(n):
binStr = " "
if n < 0:
raise ValueError, "must be a positive integer"
if n == 0:
return eval("0")
while n > 0:
binStr = str(n%2) + binStr
n = n >> 1
return eval(binStr)
def main():
#sets up while loop parameters
n = input("How many iterations?: ")
i = 0
sum = 0.0
#initial variables, iter = 0
a = [0]
arraySum = []
initBinArray = []
initializer = [0]
outputArray = [0]
storeArray = initializer
storeArray[0] = initializer[0] + 1
String = ""
print "0th iteration\t", a, "\n"
#while loop to nth iterations
while i in range(n):
#prior array incremented by one to new array
for p in range(2**(i)):
outputArray[p] += 1
#prior array and adds to current array
for q in range(2**(i)):
outputArray.append(storeArray[q]-1)
#sums elements of array
for r in range(len(outputArray)):
sum += outputArray[r]
arraySum.append(sum)
#coverts elements of outputArray to binary; then coverts entire array contents to string
for z in range(len(outputArray)):
initBinArray.append(DenaryToBinary(outputArray[z]))
String += str(initBinArray[z])
#output data
print str(i+1)+"th iteration", "\t", outputArray
print str(i+1)+"th iteration sum: ", sum
print "Conversion value:", int(String,2), "\n"
#reconfiguring critical variables
i += 1
initBinArray = []
storeArray = outputArray
String = ""
sum = 0.0
#ratio of sequential elements
#for j in range(len(d)-1):
# ratio = d[j+1]/d[j]
# print j, "\t", ratio
#limit(ratio, as j approaches infinity) = 2
main()

New Topic/Question
Reply




MultiQuote



|