Skip to content

Reading the number series without using a loop  #27

Description

@akshit-bhatt

def ShowNumber(N, Original, K, flag):
#To print the number
print(N, end = " ")
# change flag if the number becomes negative

if (N <= 0): 
    if(flag==0): 
        flag = 1
    else: 
        flag = 0
      
# base condition for second_case (Adding K) 
  
if (N == Original and (not(flag))): 
    return
  
# if flag == true, we subtract value until the number is greater then zero 
if (flag == True): 
    ShowNumber(N - K, Original, K, flag) 
    return
# second case (Addition ) 
if (not(flag)): 
    ShowNumber(N + K, Original, K, flag); 
    return

N = 20
K = 6
ShowNumber(N, N, K, True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions