The task is to get input (n) and make a list from 2 to n and remove its multiples from the list by applying recursive functions. Example: Input: 6 Output: [2, 3, 4, 5, 6]
The task is to get input (n) and make a list from 2 to n and remove its multiples from the list by applying recursive functions.
Example:
Input: 6
Output: [2, 3, 4, 5, 6]
How to apply this python code in the task?
def createList(n):
#Base Case/s
#TODO: Add conditions here for your base case/s
#if <condition> :
#return <value>
#Recursive Case/s
#TODO: Add conditions here for your recursive case/s
#else:
#return <operation and recursive call>
#remove the line after this once you've completed all the TODO for this function
return []
def removeMultiples(x, arr):
#Base Case/s
#TODO: Add conditions here for your base case/s
#if <condition> :
#return <value>
#Recursive Case/s
#TODO: Add conditions here for your recursive case/s
#else:
#return <operation and recursive call>
#remove the line after this once you've completed all the TODO for this function
return []
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images