JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="num" placeholder="num">
<button>Узнать</button>
<h1>Результат</h1>

CSS

h1 {
  padding: 10px;
  border: 1px solid #ccc;
  text-align: center;
}

JavaScript

// hexlet course  =>   Введение в программирование
// author         =>   Roman Zharikov (zharikov.site)

//document.addEventListener("DOMContentLoaded", function() {

const smallestDivisor = (num) => {
    // BEGIN
  const iter = (acc) => {
    // We use 'num / 2' in the condition below, and not 'num'.
    // This is a simple optimization: a number cannot be divided
    // by a number larger than its half.
    if (acc > num / 2) {
      return num;
    }
    if (num % acc === 0) {
      return acc;
    }
    return iter(acc + 1);
  };

  return iter(10);
  // END
};

var button = document.getElementsByTagName('button')[0],
  out = document.getElementsByTagName('h1')[0],
  input = document.getElementById('num');

button.addEventListener('click', function() {
  out.innerHTML = smallestDivisor(parseInt(input.value));
});

//});