You are given a number ‘n’. You have to tell whether a number is great or not. A great number is a number whose sum of digits let (m) and product of digits let(j) when summed together gives the number back m+j=n
You are given a number ‘n’. You have to tell whether a number is
great or not. A great number is a number whose sum of digits let (m) and
product of digits let(j) when summed together gives the number back
m+j=n
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 a = parseInt(data[0]);
var b= String(a);
var c=[]
for(i=0;i<b.length;i++)
{c[i]=b[i]}
var sum=0;
for(i=0;i<c.length;i++)
{sum=sum+Number(c[i])}
var product=1;
for(i=0;i<c.length;i++)
{product=product*Number(c[i])}
var d=sum+product
if(d==a)
console.log("Great");
else
console.log("no");
});
m+j=n
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 a = parseInt(data[0]);
var b= String(a);
var c=[]
for(i=0;i<b.length;i++)
{c[i]=b[i]}
var sum=0;
for(i=0;i<c.length;i++)
{sum=sum+Number(c[i])}
var product=1;
for(i=0;i<c.length;i++)
{product=product*Number(c[i])}
var d=sum+product
if(d==a)
console.log("Great");
else
console.log("no");
});
Comments
Post a Comment