desislava_topuzakova

01

Apr 10th, 2021
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function solve(input) {
  2. let n = Number(input[0]);
  3.  
  4. let count = 1;
  5. let flag = false;
  6.  
  7. for (let i = 1; i <= n; i++) {
  8. let output = "";
  9. for (let j = 0; j < i; j++) {
  10. output += count + " ";
  11.  
  12. if (count === n) {
  13. flag = true;
  14. break;
  15. }
  16.  
  17. count++;
  18. }
  19. console.log(output);
  20.  
  21. if (flag) {
  22. break;
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment