8 kyu

Powers of 2

862 of 67,586wichu

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

Stats:

CreatedAug 2, 2016
PublishedAug 2, 2016
Warriors Trained102158
Total Skips7824
Total Code Submissions155797
Total Times Completed67586
Haskell Completions862
Python Completions23495
CoffeeScript Completions46
JavaScript Completions26260
Ruby Completions1527
C# Completions2313
F# Completions297
OCaml Completions292
Julia Completions69
Java Completions4580
C++ Completions4993
C Completions1258
COBOL Completions34
λ Calculus Completions19
Factor Completions23
Go Completions1913
Lua Completions233
RISC-V Completions33
BF Completions52
TypeScript Completions790
Rust Completions696
D Completions15
Prolog Completions11
PHP Completions100
Total Stars616
% of votes with a positive feedback rating92% of 5131
Total "Very Satisfied" Votes4351
Total "Somewhat Satisfied" Votes692
Total "Not Satisfied" Votes88
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