Advertisement
MarkUa

Untitled

Sep 9th, 2019
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.02 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>lab1</title>
  6.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  7. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  8. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  9. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  10.  
  11. <style>
  12.     .inner{
  13.         margin: 30px 30px;
  14.     }
  15.     .description{
  16.  
  17.     }
  18. </style>
  19. </head>
  20. <body>
  21. <div class = "inner">
  22.     <div class = "description">
  23.         <h4 align="center">The values are generated using recurrence expression Xn+1 = (Xn*a + c) mod m</h4>
  24.     </div>
  25.     <h5>modul m , 0 < m </h5>
  26. <div class="alert alert-primary" role="alert">
  27.   2^12-1
  28. </div>
  29.       <h5>multiplier a, 0 < a < m </h5>
  30. <div class="alert alert-primary" role="alert">
  31. 4^5
  32. </div>
  33.       <h5>increment c, 0 <= c < m </h5>
  34. <div class="alert alert-primary" role="alert">
  35. 2
  36. </div>
  37.       <h5>start value x0, 0 <= x0 <= m </h5>
  38. <div class="alert alert-primary" role="alert">
  39. 8
  40. </div>
  41.  
  42.     <input id="count" type="number" value="1" min="1" max="25" step="1"/>
  43.     <br>
  44. <button type="button" class="btn btn-primary btn-block btn-lg" onclick="generate()">Generate numbers</button>
  45. <div class="form-group shadow-textarea">
  46.     <br>
  47.  <!-- <label for="exampleFormControlTextarea6">Shadow and placeholder</label>-->
  48.   <textarea class="form-control z-depth-1" id="exampleFormControlTextarea6" rows="4" placeholder="generated numbers..."></textarea>
  49. </div>
  50. </div>
  51. <script src="./src/bootstrap-input-spinner.js"></script>
  52. <script>
  53.     $("input[type='number']").inputSpinner()
  54.     var $changedInput = $("#count")
  55. var $valueOnInput = $("#count")
  56. var $valueOnChange = $("#count")
  57. $changedInput.on("input", function (event) {
  58. //alert("ff");
  59.     $valueOnInput.html($changedInput.val())
  60.    // alert("hello")
  61. })
  62. $changedInput.on("change", function (event) {
  63.    // alert("ff");
  64.     $valueOnChange.html($changedInput.val())
  65.    // alert("hel")
  66. })
  67.     function generate() {
  68.         $("textarea#exampleFormControlTextarea6").val("");
  69.         alert($valueOnChange.val());
  70.         var m = Math.pow(2, 14) - 1
  71.         var a = Math.pow(6, 5)
  72.         var c = 2;
  73.         var x0 = 8;
  74.  
  75.         var result = "";
  76.         for (var i = 0; i < $valueOnChange.val(); i++) {
  77.            x0 = (a * x0 + c) % m;
  78.            result = result + " " + x0.toString();
  79.        }
  80.        $("textarea#exampleFormControlTextarea6").val(result);
  81.  
  82.    }
  83. </script>
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement