Given x and y as input. Print all the power of x from 1 to y. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Given x and y as input. Print all the power of x from 1 to y.

test case: input x=17,y=3, output : 17#289#4913#

17th Feb 2018, 2:00 PM
Roshan Kumar
Roshan Kumar - avatar
1 Answer
+ 1
javascript (es6) let x = 17, y = 3; document.write(Array.from({'length':y}, (_,i) => x**(i+1)).join('<br>'));
17th Feb 2018, 2:43 PM
Schindlabua
Schindlabua - avatar