Using the method of looping, write a program to print the table of 9 till N in the format as follows: (N is input by the user)
Using the method of looping, write a program to print the table of 9 till N in the format as follows:
(N is input by the user)
9 18 27...
Print NULL if 0 is input
Input Description:
A positive integer is provided as an input.
Output Description:
Print the table of nine with single space between the elements till the number that is input.
Sample Input :
3
Sample Output :
9 18 27
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var N = parseInt(data[0]);
var a=[];
for(i=1;i<=N;i++)
{a[i-1]=9*i;}
var b="";
for(i=0;i<N;i++)
{if(i==N-1)
b=b+a[i]
else
(b=b+a[i]+" ")
}
console.log(b)
});
Comments
Post a Comment