title: javascript calculate function
body: <p>This JS program should return function ggt(x,z). I tried to implement it this way, everything is ok except this part I believe: <code>document.getElementById("demo").innerHTML=ggt(x,z);</code> 
  What should be added to make this function work properly? Thanks</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;   
      function calculate(){
          var a=document.getElementById("in1").value;
          var b=document.getElementById("in2").value;
          if(isNaN(a) || isNaN(b)){
            alert("Not a number");
          }else{
            ggt(a,b);
          }
      }
  
      function ggt(x,y){
          if (y==0){
              return x;
          }else{
              var z=x%y; 
              document.getElementById("demo").innerHTML=ggt(x,z);
              return ggt(x,z);
          }
      }
  &lt;/script&gt; 
  &lt;div&gt;
  &lt;input id="in1" type="text" /&gt;
  &lt;input id="in2" type="text" /&gt;
  &lt;input type="button" onclick="calculate()" value="compute" /&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>