Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- startAlgorithm()
- def fibonacciSeq(n):
- a = 0
- b = 1
- for i in range(0, n - 2):
- c = a + b
- a = b
- b = c
- return c
- characters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
- def startAlgorithm():
- while True:
- userInput = input("Enter the nth number Fibonacci sequence for the key then ; and then the word you want encoded: ")
- output = ""
- if userInput < 0:
- break
- n = int(userInput[0:userInput.find(';')])
- word = userInput[userInput.find(';') + 1:]
- for i in range(0, len(word)):
- output += characters[(characters.index(word[i].upper())
- + fibonacciSeq(n + i)) % 26]
- print(output)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement