georgiev955

Divisible by 9

Feb 25th, 2023
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let start = Number(input[0]);
  3.     let end = Number(input[1]);
  4.     let sum = 0;
  5.     for (let i = start; i < end; i++) {
  6.         if (i % 9 == 0) {
  7.             sum+=i;
  8.         }
  9.     }
  10.     console.log(`The sum: ${sum}`);
  11.     for (let j = start; j < end; j++) {
  12.         if (j % 9 == 0) {
  13.             console.log(j);
  14.         }
  15.     }
  16. }  
Advertisement
Add Comment
Please, Sign In to add comment