menu
techminis

A naukri.com initiative

google-web-stories
source image

Dev

1w

read

105

img
dot

Image Credit: Dev

Powers of 2

  • The function takes a non-negative integer n as input.
  • It returns a list of all the powers of 2 with the exponent ranging from 0 to n (inclusive).
  • For example, if n is 0, it returns [1].
  • The solution involves creating an array, using a loop to calculate the powers of 2, and adding them to a new array.

Read Full Article

like

6 Likes

For uninterrupted reading, download the app