The following recursive function will print the nth power of 2. def powerOf2(n): if n == 0: return 1 else: return (2 * powerOf2(n - 1)) (1 point) Responses Image with alt text: A rectangle is labeled ‘power Of 2 left parenthesis n right parenthesis.’ An arrow originates from the rectangle connects to a rhombus. The rhombus is labeled ‘n equals equals 0.’ Two arrows originate from the rhombus. An arrow labeled ‘Yes’ connects to a rectangle labeled ‘Return 2 superscript n baseline.’ Another arrow labeled ‘No’ connects to a rectangle labeled ‘left parenthesis n right parenthesis equals left parenthesis n minus 1 right parenthesis.’ An arrow originates from this rectangle and connects to the first rectangle labeled ‘power Of 2 left parenthesis n right parenthesis.’ Image with alt text: A rectangle is labeled ‘power Of 2 left parenthesis n right parenthesis.’ An arrow originates from the rectangle connects to a rhombus. The rhombus is labeled ‘n equals equals 0.’ Two arrows originate from the rhombus. An arrow labeled ‘Yes’ connects to a rectangle labeled ‘Return 1.’ Another arrow labeled ‘No’ connects to a rectangle labeled ‘left parenthesis n right parenthesis equals left parenthesis n minus 1 right parenthesis.’ An arrow originates from this rectangle and connects to the first rectangle labeled ‘power Of 2 left parenthesis n right parenthesis.’ Image with alt text: A rectangle is labeled ‘power Of 2 left parenthesis n right parenthesis.’ An arrow originates from the rectangle connects to a rhombus. The rhombus is labeled ‘n equals equals 2.’ Two arrows originate from the rhombus. An arrow labeled ‘Yes’ connects to a rectangle labeled ‘Return 1.’ Another arrow labeled ‘No’ connects to a rectangle labeled ‘left parenthesis n right parenthesis equals left parenthesis n minus 1 right parenthesis.’ An arrow originates from this rectangle and connects to the first rectangle labeled ‘power Of 2 left parenthesis n right parenthesis.’
1 answer
Image with alt text: A rectangle is labeled ‘power Of 2 left parenthesis n right parenthesis.’ An arrow originates from the rectangle connects to a rhombus. The rhombus is labeled ‘n equals equals 0.’ Two arrows originate from the rhombus. An arrow labeled ‘Yes’ connects to a rectangle labeled ‘Return 1.’ Another arrow labeled ‘No’ connects to a rectangle labeled ‘left parenthesis n right parenthesis equals left parenthesis n minus 1 right parenthesis.’ An arrow originates from this rectangle and connects to the first rectangle labeled ‘power Of 2 left parenthesis n right parenthesis.’