Mountain Sequence Pattern | Python3 program for the above approach ; Function to print pattern recursively ; Base Case ; Condition to check row limit ; Condition for assigning gaps ; Conditions to print * ; Else print '  ; Recursive call for columns ; Recursive call for rows ; Given Number N ; Function Call
k1 = 2 NEW_LINE k2 = 2 NEW_LINE gap = 5 NEW_LINE def printPattern ( i , j , n ) : NEW_LINE INDENT global k1 NEW_LINE global k2 NEW_LINE global gap NEW_LINE if ( j >= n ) : NEW_LINE INDENT k1 = 2 NEW_LINE k2 = 2 NEW_LINE k1 -= 1 NEW_LINE k2 += 1 NEW_LINE if ( i == 2 ) : NEW_LINE INDENT k1 = 0 NEW_LINE k2 = n - 1 NEW_LINE DEDENT return 0 NEW_LINE DEDENT if ( i >= 3 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( j > k2 ) : NEW_LINE INDENT k1 += gap NEW_LINE k2 += gap NEW_LINE DEDENT if ( j >= k1 and j <= k2 or i == 2 ) : NEW_LINE INDENT print ( " * " , end = " " ) NEW_LINE DEDENT DEDENT ' NEW_LINE INDENT else : NEW_LINE INDENT print ( " ▁ " , end = " " ) NEW_LINE DEDENT if ( printPattern ( i , j + 1 , n ) == 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT print ( ) NEW_LINE return ( printPattern ( i + 1 , 0 , n ) ) NEW_LINE DEDENT N = 3 NEW_LINE printPattern ( 0 , 0 , N * 5 ) NEW_LINE