mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Added Syracuse sequence.
This commit is contained in:
parent
1c2181e6f1
commit
98bebe3117
1 changed files with 15 additions and 0 deletions
|
@ -99,6 +99,21 @@ def fibonacci():
|
|||
a, b = b, a + b
|
||||
|
||||
|
||||
def syracuse(l=15):
|
||||
n = 0
|
||||
while True:
|
||||
yield syracuse_gen(n, l)
|
||||
n += 1
|
||||
|
||||
def syracuse_gen(n, l=15):
|
||||
if n == 0:
|
||||
return l
|
||||
if n % 2 == 0:
|
||||
return syracuse_gen(n-1)/2
|
||||
elif n % 2 == 1:
|
||||
return 3*syracuse_gen(n-1)+1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Point of entry in execution mode.
|
||||
f = fibonacci()
|
||||
|
|
Loading…
Add table
Reference in a new issue