{"id":53098,"date":"2021-08-28T03:01:53","date_gmt":"2021-08-27T17:01:53","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=53098"},"modified":"2021-08-28T11:55:34","modified_gmt":"2021-08-28T01:55:34","slug":"prime-numbers-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/prime-numbers-primer-tutorial\/","title":{"rendered":"Prime Numbers Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/fractional_prime.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Prime Numbers Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/fractional_prime.jpg\" title=\"Prime Numbers Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Prime Numbers Primer Tutorial<\/p><\/div>\n<p>We&#8217;ve been itching to do a &#8220;Prime Numbers Primer Tutorial&#8221; but haven&#8217;t found an interesting enough &#8220;in&#8221;.  But I had occasion to want to count down an hour long period of time the other day, and wondered at the number patterns, or not, as the case may be that thinking about the positive integers involved, and whether they represent a <a target=_blank title='Prime number information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Prime_number'>prime number<\/a> &#8230;<\/p>\n<blockquote cite='https:\/\/en.wikipedia.org\/wiki\/Prime_number'><p>\nA prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 \u00d7 5 or 5 \u00d7 1, involve 5 itself. However, 4 is composite because it is a product (2 \u00d7 2) in which both numbers are smaller than 4. Primes are central in number theory because of the fundamental theorem of arithmetic: every natural number greater than 1 is either a prime itself or can be factorized as a product of primes that is unique up to their order.Prime Numbers Primer Tutorial\n<\/p><\/blockquote>\n<p> &#8230; or not.  That whiled away that hour and made me think to involve fractions as well as these &#8220;prime number&#8221; considerations might make for a slightly interesting &#8220;take&#8221; on this &#8220;well worn&#8221; subject <font size=1>(or the uncharitable might say &#8230; &#8220;looking for patterns where there are none&#8221;)<\/font>.  Our major Javascript function goes like &#8230;<\/p>\n<p><code><br \/>\nfunction fcalc() {<br \/>\n  var assessment=' is a prime number.';<br \/>\n  var innards='', facline='&lt;tr id=tr2>&lt;\/tr>', divline='&lt;tr id=tr3>&lt;\/tr>', diffsline='&lt;tr id=tr4>&lt;td colspan=' + divisors.length + '>&lt;table style=\"width:100%;text-align:center;\" border=1>&lt;tr>&lt;td id=td0>&lt;\/td>&lt;\/TR>&lt;\/table>&lt;\/td>&lt;\/tr>';<br \/>\n  var lastii=-1;<br \/>\n  var huhti=1, rect=null, lastrect=null;<br \/>\n  for (var ii=mynum; ii>=1; ii--) {<br \/>\n    if (('' + eval(mynum \/ ii)).indexOf('.') == -1) {<br \/>\n      divisors.push(ii);<br \/>\n      if (eval('' + divisors.length) > 2) { assessment=' is not a prime number.'; }<br \/>\n      facline=facline.replace('&lt;\/tr>', '&lt;td>1\/' + ii + '&lt;\/td>&lt;\/tr>');<br \/>\n      divline=divline.replace('&lt;\/tr>', '&lt;td id=dt' + divisors.length + '>' + eval(mynum \/ ii) + '&lt;\/td>&lt;\/tr>');<br \/>\n      if (('' + lastii).indexOf('-') != -1) {<br \/>\n        lastii=eval(mynum \/ ii);<br \/>\n      } else {<br \/>\n        diffs.push(eval(eval(mynum \/ ii) - lastii));<br \/>\n        diffsline=diffsline.replace('&lt;\/TR>', '&lt;td id=td' + diffs.length + '>' + eval(eval(mynum \/ ii) - lastii) + '&lt;\/td>&lt;\/TR>');<br \/>\n        lastii=eval(mynum \/ ii);<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n  innards+='&lt;tr id=tr1>&lt;td colspan=' + divisors.length + '>&lt;a onclick=ask(); style=\"cursor:pointer;text-decoration:underline;\">' + mynum + '&lt;\/a>&lt;span id=shuh>' + assessment + '&lt;\/span>&lt;\/td>&lt;\/tr>' + facline + divline + diffsline.replace(' colspan=0', ' colspan=' + divisors.length).replace('&lt;\/TR>','&lt;td id=xxx>&lt;\/td>&lt;\/tr>');<br \/>\n  document.getElementById('mytable').innerHTML=innards;<br \/>\n  while (document.getElementById('dt' + huhti)) {<br \/>\n    rect=document.getElementById('dt' + huhti).getBoundingClientRect();<br \/>\n    if (huhti == 1) {<br \/>\n      document.getElementById('td0').style.width='' + eval(eval('' + rect.width) \/ 2) + 'px';<br \/>\n      document.getElementById('xxx').style.width='' + eval(eval('' + rect.width) \/ 2) + 'px';<br \/>\n    }<br \/>\n    if (document.getElementById('dt' + eval(1 + huhti))) {<br \/>\n    if (lastrect) {<br \/>\n      \/\/alert( eval(eval(eval('' + rect.x) - eval('' + lastrect.x)) \/ 2));<br \/>\n      \/\/document.getElementById('td' + huhti).style.left='' + eval(eval(eval('' + rect.left) - eval('' + lastrect.left)) \/ 2) + 'px';<br \/>\n      document.getElementById('td' + huhti).style.width='' + lastrect.width + 'px';<br \/>\n    } else {<br \/>\n      document.getElementById('td' + huhti).style.width='' + rect.width + 'px';<br \/>\n    }<br \/>\n    }<br \/>\n    lastrect=rect;<br \/>\n    huhti++;<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; for a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/fractional_prime.html_GETME\" title=\"fractional_prime.html\">&#8220;proof of concept&#8221; fractional_prime.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/fractional_prime.html\" title=\"Click picture\">live run<\/a> link for you to try, should you be curious.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d53098' onclick='var dv=document.getElementById(\"d53098\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/mathematics\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d53098' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve been itching to do a &#8220;Prime Numbers Primer Tutorial&#8221; but haven&#8217;t found an interesting enough &#8220;in&#8221;. But I had occasion to want to count down an hour long period of time the other day, and wondered at the number &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/prime-numbers-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[576,652,752,3740,3741,997,1238,1319,2257],"class_list":["post-53098","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-html","tag-javascript","tag-mathematics","tag-prime","tag-prime-number","tag-programming","tag-table","tag-tutorial","tag-width"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/53098"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=53098"}],"version-history":[{"count":8,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/53098\/revisions"}],"predecessor-version":[{"id":53115,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/53098\/revisions\/53115"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=53098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=53098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=53098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}