Mageia Bugzilla – Attachment 10219 Details for
Bug 22983
python3 new security issues CVE-2018-1060, CVE-2018-1061, and CVE-2017-18207
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Generates fibonacci numbers
fibonacci.py (text/x-python), 586 bytes, created by
Len Lawrence
on 2018-06-03 12:39:28 CEST
(
hide
)
Description:
Generates fibonacci numbers
Filename:
MIME Type:
Creator:
Len Lawrence
Created:
2018-06-03 12:39:28 CEST
Size:
586 bytes
patch
obsolete
>#!/bin/env python3 > >import itertools > >def fib( n ): > a, b = 0, 1 > for i in range( n ): > a, b = b, a + b > return a > >def fiblist( n ): > fib = [0, 1] > for i in range( 1, n ): > fib += [fib[-1] + fib[-2]] > return fib > >def fibo( ): > ''' Unbounded generator for Fibonacci numbers ''' > x, y = 0, 1 > while True: > yield x > x, y = y, x + y > >a = fiblist( 13 ) > >print( "Fibonacci series for first 13 terms" ) >print( str( a ).strip( '[]' ) ) >print( "The tenth term is %d" % a[9] ) > >print( list( itertools.islice( fibo( ), 10 ) ) ) > >exit( )
#!/bin/env python3 import itertools def fib( n ): a, b = 0, 1 for i in range( n ): a, b = b, a + b return a def fiblist( n ): fib = [0, 1] for i in range( 1, n ): fib += [fib[-1] + fib[-2]] return fib def fibo( ): ''' Unbounded generator for Fibonacci numbers ''' x, y = 0, 1 while True: yield x x, y = y, x + y a = fiblist( 13 ) print( "Fibonacci series for first 13 terms" ) print( str( a ).strip( '[]' ) ) print( "The tenth term is %d" % a[9] ) print( list( itertools.islice( fibo( ), 10 ) ) ) exit( )
View Attachment As Raw
Actions:
View
Attachments on
bug 22983
: 10219 |
10220
|
10222