Good people, help, really need help. It is necessary to write a function that iterates over integers from 0 to infinity and displays, comma-separated, those that are divided without remainder by the number of digits (signs) of this number (that is, those two-digit ones that are divided by 2, three-digit ones by three etc.). Processing should stop at the moment when N (user-defined) such numbers are displayed.

<html> <head> <title>Test</title> <link href="main.css" rel="stylesheet"> </head> <body> <div id="task"> <h1>Test</h1> <p>Функция, которая перебирает целые числа от 0 до бесконечности и выводит на экран, через запятую, те, которые делятся без остатка на количество разрядов (знаков) этого числа (т.е.те двухзначные, которые делятся на 2, трехзначные на три и т.д.). Выполнение обработки должно остановиться в тот момент, когда всего будет выведено N (задается пользователем) таких чисел.</p> <input type="number" id="cnt" /><input type="button" id="btn" value="OK" onclick="fill();"/> </div> </br> <div id="inform"></div> </body> </html> 

Closed due to the fact that the participants are off topic: Igor , user207618, nick_n_a , 0xdb , cheops 7 Jul '18 at 5:33 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- Igor, Community Spirit, nick_n_a, 0xdb, cheops
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • I wonder where does your html code? ) - Muzaffar Rasulov

1 answer 1

Something like that?

 var n = prompt('Enter N:'), result = ''; var count = 0; for (var i = 0; count < n; i++) { if (i % i.toString().length == 0) { result += i + ', '; count++; } } console.log(result); 

  • Thank you so much - user302628 '13
  • @ user302628, not at all :) - entithat