Post Reply 
Generate the largest Prime Number
02-07-2018, 07:33 PM (This post was last modified: 02-07-2018 07:35 PM by Dieter.)
Post: #5
RE: Generate the largest Prime Number
(02-07-2018 09:26 AM)Gamo Wrote:  The highest prime number that fill 10 digits calculator screen is 9,999,999,997
The next prime is 10,000,000,019 which is 11 digits that can't fill in the screen.

1000000001 R/S result 9 > 10,000,000,019
(...)
1000000001 R/S result 03 > 10,000,000,103

I assume the last line is supposed to read

1000000010 R/S result 3 > 10,000,000,103

Now, what do you want to get if you enter a 10-digit number like 1.000.000.001?

- The next prime with 11 digits?
That's 10.000.000.019, so the output is 9 ?
This means: determine the next prime after 10*x.

- The next prime with 12 digits?
That's 100.000.000.103, so the output is 03 ?
This means: determine the next prime after 100*x.

- The next prime with 13 digits?
That's 1.000.000.001.051, so the output is 051 ?
This means: determine the next prime after 1000*x.

Let's assume you mean the first case. "Determine the next prime" here simply means:
Check if the following numbers are prime:
10*x+1, 10*x+3, 10*x+7 and 10*x+9

So it boils down to an algorithm like this:

Code:
input x
found=false

p = 10*x+1
checkprime(p)
p = 10*x+3
checkprime(p)
p = 10*x+7
checkprime(p)
p = 10*x+9
checkprime(p)

if not found then print "No primes between " 10*x " and " 10*x+9
end

subroutine checkprime(p):
if isprime(p) then 
  print p
  found=true
end

Now, how do you check if an 11-digit number is divisible by, say, 7 while all you got is a 10-digit calculator? I'd say this can be done. Think hard. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Generate the largest Prime Number - Gamo - 02-06-2018, 03:05 AM
RE: Generate the largest Prime Number - Dieter - 02-07-2018 07:33 PM



User(s) browsing this thread: 1 Guest(s)