Question: Star wars recursion Define a recursive function star _ wars _ recursive that takes a parameter num _ enemy _ ships and returns a string

Star wars recursion
Define a recursive function star_wars_recursive that takes a parameter num_enemy_ships and returns a string command to take down all the enemy ships.
The string command will comprise of alternating beams: '*-' and '*--'
For example:
star_wars_recursive(3) will return '*-*--*-'
star_wars_recursive(6) will return '*-*--*-*--*-*--'
star_wars_recursive(0) will return ''
Explanation of the first and second examples:
star_wars_iteration(3) return value is formed by '*-'+'*--'+'*-'
star_wars_iteration(6) return value is formed by '*-'+'*--'+'*-'+'*--'+'*-'+'*--'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!