Twitter

  • Follow strider_sj on TwitterNew posts and updates will be announced on my twitter account.Follow strider_sj on Twitter
  • Follow me on Twitter

The SJ Wayback Machine

Blogs in Canada

See blogs and businesses for Canada

Link Categories

Random Post

Categories

How to spend an idle afternoon

Yesterday, I told another fellow computer geek an ’80s DOS joke about being prompted to “Enter any 11-digit prime number and press ENTER to continue.” She then suggested that a number with 11 1’s might be prime.  Having encountered this before in programs I’ve written, I warned her that you can’t assume all sequences of 1’s are prime, having previously tried this on numbers like 11; 111  1,111; 11,111; 111,111 and so on. 1 itself is neither prime nor composite, so it doesn’t count.

But of course, was 11,111,111,111 prime? There was no direct way of knowing that, and even an attempt to write a C program ran me into trouble, since said number is one digit beyond double precision, and I can’t get the “%” operator to work with floating point anyway. Long int will cause an overflow; casting long double as any kind of int will result in undefined behaviour. And admittedly, I didn’t want to spend hours at this. The only thing that came out of this is that I needed to brush up on my C coding.

The prime detectors I saw on the web also choked on 11 digit numbers. There were exceptions, however. The prime number calculator at math.com could do it. 21,649 was a factor of 11,111,111,111.

(Late edit) I tried using Maple to find primes consisting of ones, and the lowest number I can find besides 11 was the number: 1,111,111,111,111,111,111, or 1 quintillion and change (maybe 1 million billion if you are old-school).

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.