ProdanTenev

Numbers, Divisible by 9

Feb 25th, 2022
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.34 KB | None | 0 0
  1. function divisibleByNine(input) {
  2.     let num = Number(input[0]);
  3.     let num1 = Number(input[1]);
  4.     let sum = 0;
  5.     let output = "";
  6.     for (let i=num; i<=num1;i++) {
  7.         if(i % 9 == 0) {
  8.             sum += i;
  9.             output += i +  "\n" ;        
  10.         }
  11.     }
  12.     console.log(`The sum: ${sum}`);
  13.     console.log(output);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment