8 kyu

Powers of 2

874 of 69,146wichu

Description:

Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to n ( inclusive ).

Examples

n = 0  ==> [1]        # [2^0]
n = 1  ==> [1, 2]     # [2^0, 2^1]
n = 2  ==> [1, 2, 4]  # [2^0, 2^1, 2^2]
  n = String.fromCharCode(0)  ==> String.fromCharCode(1)
  n = String.fromCharCode(1)  ==> String.fromCharCode(1) + String.fromCharCode(2)
  n = String.fromCharCode(2)  ==> String.fromCharCode(1) + String.fromCharCode(2) + String.fromCharCode(4)
Mathematics
Fundamentals

Similar Kata:

Stats:

CreatedAug 2, 2016
PublishedAug 2, 2016
Warriors Trained104275
Total Skips8050
Total Code Submissions159054
Total Times Completed69146
Haskell Completions874
Python Completions24100
CoffeeScript Completions47
JavaScript Completions26634
Ruby Completions1534
C# Completions2368
F# Completions299
OCaml Completions296
Julia Completions71
Java Completions4690
C++ Completions5193
C Completions1286
COBOL Completions34
λ Calculus Completions19
Factor Completions23
Go Completions2021
Lua Completions244
RISC-V Completions34
BF Completions55
TypeScript Completions833
Rust Completions724
D Completions18
Prolog Completions11
PHP Completions134
Total Stars626
% of votes with a positive feedback rating92% of 5193
Total "Very Satisfied" Votes4404
Total "Somewhat Satisfied" Votes700
Total "Not Satisfied" Votes89
Ad
Contributors
  • wichu Avatar
  • jhoffner Avatar
  • spencerwi Avatar
  • suic Avatar
  • anter69 Avatar
  • donaldsebleung Avatar
  • AcesOfGlory Avatar
  • kazk Avatar
  • user5036852 Avatar
  • JohanWiltink Avatar
  • Voile Avatar
  • monadius Avatar
  • user5813877 Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • yavidor Avatar
  • SergeySinyavskiy Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • Just4FunCoder Avatar
  • NikCSharp Avatar
  • MingLeeNg Avatar
  • 4500zenja1 Avatar
  • fcr-- Avatar
  • KayleighWasTaken Avatar
  • AmirTallap Avatar
Ad