λ式(ラムダ式)と条件式(条件分岐演算子;三項演算子)

rec_fibonacci = \
    lambda n: \
        0 if n == 0 else \
                     ( 1 if n == 1 else \
                                   ( rec_fibonacci( n - 2 ) + \
                                     rec_fibonacci( n - 1 ) ) )

for i in range( 11 ):
    print( rec_fibonacci( i ) )

SoftEng: Python/Prog/Practice/Basic/02/BP_005a/AdvancedTopics (last edited 2018-10-28 15:42:09 by TadashiIijima)