Difference between revisions of "Prime"

From Freephile Wiki
Jump to navigation Jump to search
(This changes nothing)
Line 27: Line 27:
 
With "workers" you can perform a computationally expensive task without interrupting the user interface.
 
With "workers" you can perform a computationally expensive task without interrupting the user interface.
  
+
 
  
 
== Word of the Day ==
 
== Word of the Day ==
- Characterized by, or having great physical beauty and appeal.
+
- Characterized by, or having great physical beauty and appeal.
  
 
{{References}}
 
{{References}}
  
 
[[Category:JavaScript]]
 
[[Category:JavaScript]]

Revision as of 09:53, 29 December 2018

Prime Real Estate[edit | edit source]

This demo page http://www.whatwg.org/demos/workers/primes/page.html from the Web Hypertext Application Technology Working Group shows prime numbers. What I found interesting is that initially, it takes a few moments to find prime numbers; meaning that they are "far apart" as you examine every number up to say 1,000,000. But suddenly the demo application is spitting out prime numbers faster than you can read. So, apparently there are a lot of prime numbers once you get into the larger numbers. But this isn't actually true. If you look at the distribution of primes, there are "more" smaller primes than larger primes (X < 200) [1]. Hmm.

<!DOCTYPE HTML>
<html>
 <head>
  <title>Worker example: One-core computation</title>
 </head>
 <body>
  <p>The highest prime number discovered so far is: <output id="result"></output></p>
  <script>
   var worker = new Worker('worker.js');
   worker.onmessage = function (event) {
     document.getElementById('result').textContent = event.data;
   };
  </script>
 </body>
</html>

Concurrency[edit | edit source]

Aside from that, this demo illustrates how HTML5 brings multi-threaded execution or concurrency to your web application.

With "workers" you can perform a computationally expensive task without interrupting the user interface.


Word of the Day[edit | edit source]

- Characterized by, or having great physical beauty and appeal.

References[edit source]