<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!DOCTYPE html>
<html>
<body>
enter the number of elements:<input type="text" id="demo">
<button onclick="method()">submit</button>
<span id="demo1"></span>
<script>
function method()
{
var s=document.getElementById("demo").value;
var a=0;
var b=1;
var c ="";
var res="0,1";
for(var i=2;i<s;i++)
{
var c=a+b;
a=b;
b=c;
res+=","+c;
}
document.getElementById("demo1").innerHTML=res;
}
</script>
</body>
</html>