Print first N terms of Lower Wythoff sequence | Python3 implementation of the approach ; Function to print the first n terms of the lower Wythoff sequence ; Calculate value of phi ; Find the numbers ; a ( n ) = floor ( n * phi ) ; Print the nth numbers ; Driver code
from math import sqrt , floor NEW_LINE def lowerWythoff ( n ) : NEW_LINE INDENT phi = ( 1 + sqrt ( 5 ) ) / 2 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ans = floor ( i * phi ) ; NEW_LINE print ( ans , end = " " ) ; NEW_LINE if ( i != n ) : NEW_LINE INDENT print ( " , ▁ " , end = " " ) ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 5 ; NEW_LINE lowerWythoff ( n ) ; NEW_LINE DEDENT