Do I have to check for all prime numbers?

I've designed a system which only takes in a prime number as an input and outputs the final digit sum of that number. For example, if I input 997 (a prime), the system will output 7:

997 9 + 9 + 7 = 25 2 + 5 = 7. 997\ \ \longrightarrow \ \ 9 + 9 + 7 = 25 \ \ \longrightarrow \ \ 2+5=7.

How many single-digit positive integers cannot be an output of this system?

0 1 2 3 4

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

Joshua Lowrance
Nov 26, 2018

19 1 + 9 = 10 1 + 0 = 1 19 \rightarrow 1 + 9 = 10 \rightarrow 1 + 0 = 1

2 2 2 \rightarrow 2

3 3 3 \rightarrow 3

13 1 + 3 = 4 13 \rightarrow 1 + 3 = 4

5 5 5 \rightarrow 5

6 n o n e 6 \rightarrow none

7 7 7 \rightarrow 7

17 1 + 7 = 8 17 \rightarrow 1 + 7 = 8

9 n o n e 9 \rightarrow none

If you recall, all multiples of 3 have a final digital sum, or a digital root , of 3, 6, or 9. The vice versa is also true, namely that all numbers that have a digital root of 3, 6, or 9 (excluding the case of 3) are divisible by 3. Therefore, no number can have a digital root of 6 or 9. However, 3 has a digital root of 3, and is prime. Above are listed examples showing that every digital root can be formed with primes, excluding 6 and 9.

0 is also an integer

斌 刘 - 2 years, 6 months ago

Log in to reply

But not a positive integer.

Thomas Raffill - 2 years, 6 months ago

Log in to reply

Here in France it is considered as positive (0 is considered as positive and negative), I guess it depends on where you learn maths

nathan oupresque - 2 years, 6 months ago

Log in to reply

@Nathan Oupresque Hi Nathan and Thomas, we are using standard English usage for the math terms and we added the definition into the problem statement.

Brilliant Mathematics Staff - 2 years, 6 months ago

Answer should be 3 integers. 0,6,9

Srikanth K - 2 years, 6 months ago

Log in to reply

Hi Srikanth, we are using standard English usage for the math terms and we added the definition into the problem statement.

Brilliant Mathematics Staff - 2 years, 6 months ago

Yes answer is 2: In english, 0 is not a positive integer.

But.. in french it is.. (and I presume in other languages too). When talking about a fraction, saying something like "the denominator is a positive integer.." has no ambiguity, but when a question is asking about digits it should include 0 in its answer..

Rémy Chauvin - 2 years, 6 months ago

Log in to reply

Hi Rémy, we are using standard English usage for the math terms and we added the definition into the problem statement.

Brilliant Mathematics Staff - 2 years, 6 months ago

Log in to reply

@Brilliant Mathematics I can’t seem to be able to post solutions of my own on daily & weekly solutions, can only reply. Also, the only ~latest~ weekly challenges that I have, are from the last year, shouldn’t they be from this week or atleast this month/year? Haha explains why am I here and as is obvious from the reply dates that’s just me. Help me, what’s going on? 💁🏼

Jingle Jungle - 1 year, 11 months ago

The wording doesn’t make sense to me. If it is a single digit being entered, how are you inputting 19 and 13?

Sherry Griffin - 2 years, 6 months ago

Log in to reply

No, you are inputting a prime number, and a single digit is being outputted.

Joshua Lowrance - 2 years, 6 months ago

Log in to reply

41? 4+1=5 67? 6+7=13 1+3=4 17? 1+7=8 73? 7+3=10 1+0=1 79? 7+9=16 1+6=7 Im not understanding

Samir Seif - 2 years, 5 months ago

For some reason I forgot to check against prime numbers less than 10, so I was initially thinking 3 as well as 6 and 9. Silly mistake.

Brandon Parker - 2 years, 6 months ago

Log in to reply

I did the same thing.

David Richner - 2 years, 5 months ago

Log in to reply

I did this mistake as well.

Arunsoumya Basu - 1 year, 11 months ago

I forgot it was only asking for positive integers and counted 0 as well... Silly me.

Gabriel Chacón - 2 years, 6 months ago

Log in to reply

Same here. As soon as i saw the solution ist two i thought "silly me!"

KisoX . - 2 years, 6 months ago

I almost made this mistake but caught it only to make the mistake of not considering the primes less than 10.

David Richner - 2 years, 5 months ago

All multiples of 3 do NOT have a digital sum of 3, 6, or 9. All multiples of 3 have a FINAL digital sum of 3, 6, or 9.

Kevin Hickey - 2 years, 6 months ago

Log in to reply

Yes, thank you.

Joshua Lowrance - 2 years, 6 months ago

one can prove it by looking at the numbers modulo 9. The number modulo nine is preserved when doing the transformation. This is because: 10 = 1 + 9 = 1 100 = 1 + 99 = 1 etcetera Any number that results in 3, 6 or 9 therefore originally must have been a multiple of 3. Since only prime numbers are considered, of these only 3 occurs - when starting with itself.

Frank van Lankvelt - 2 years, 6 months ago

You did not say that the inputs were limited to prime numbers. You said that if a prime number was entered, that it would return the last digit of the prime.

Kermit Rose - 2 years, 6 months ago

Log in to reply

First, he did not say that it would return the last digit of the prime, he said it would return the final digit SUM of the prime. But yes, I see your confusion. It is inferred that the inputs were limited to prime numbers, but maybe they can add clarification?

Joshua Lowrance - 2 years, 6 months ago

I agree with the first sentence of Kermit's post. That is misleading.

Félix Pérez Haoñie - 2 years, 5 months ago

What is a digital root?

Aman thegreat - 2 years, 5 months ago

Log in to reply

A digital root is a final digital sum, or a repeated digital sum until you have one digit. For example, take 2589. Adding the digits you get 24. Then, adding the digits again you get 6. So 6 is the digital root of 2589. Here is a wiki page on it.

Joshua Lowrance - 2 years, 5 months ago

Very smart explanation!!!

Jaimy Sajit - 2 years, 5 months ago

Nothing is stated in the question to feed only primes to the program: «How many single-digit positive integers cannot be an output of this system?». You can make a program for something and then try it for other purposes, included if you only want to enjoy how crazy the outputs can be. (It's a common practice among programmers to try their programs out of theis limits just to check if they behave properly). If one feeds 996 the output would be 6. I think it should be reworded to avoid misunderstandings.

Félix Pérez Haoñie - 2 years, 5 months ago

Log in to reply

Thank you for your astute observation. I've updated the problem statement to reflect this.

In the future, if you have concerns about a problem's wording/clarity/etc., you can report the problem. See how here .

Brilliant Mathematics Staff - 2 years, 5 months ago

Log in to reply

Ok, thank you.

Félix Pérez Haoñie - 2 years, 4 months ago

TIL 0 isn't considered a positive number

Xavi Ramirez - 2 years, 5 months ago

Badly worded. Also not clear if 0 and 2 are considered to be primes

Alan Griffiths - 2 years, 5 months ago

For those seeking a different approach. The lowest prime Numbers in that sequence could have gotten a 3 and maybe a 2. 1 nothing can get 1 and 0. 2

Oluwaseyi Lawal - 2 years, 5 months ago

I had to read a thousand times! Basically because numbers that have a digital root of 3, 6 and 9 are all dividable by three they cannot be prime numbers. Therefore, they cannot be inputed. Therefore, no 3, 6 or 9. Except that 3 is a prime number and has a digital root of 3. So in the end you still add 3 to the list.

Jounaid Beaufils - 2 years, 5 months ago

Realistically, the problem only states how the system was designed. It fails to mention that the system is perfect and inviolate. It's not safe to assume anything "cannot" be an output. If I hit it with a sledgehammer, it might output smiley faces. Since this problem is so nitpicky, the answer is 0. That it SHOULD NOT output a 6 or 9 doesn't mean it CANNOT.

nunya beezwax - 2 years, 5 months ago

Call it cognitive bias but, I was not going to consider leading zeros (0 + a prime number). Therefore I rejected the notion of any sum less than two positive integers. The kind of question that might be good for stumping some of your friends.

Tim Rammel - 2 years, 5 months ago

51 is a prime number which add upto 6. Then answer must be 1

Kavin P - 2 years, 3 months ago

Log in to reply

51 51 is not a prime: 3 × 17 = 51 3 \times 17 = 51

Joshua Lowrance - 2 years, 3 months ago

Hey I probably got this completely wrong but shouldn't the answer be 0? 1 > 1 11 > 2 111 > 3 etc.?

Elsa Heege - 2 years, 1 month ago

Log in to reply

Not all forms of 111 111 111 \cdots 111 are prime. For example, 111 111 is divisible by 3 3 ; 1111 1111 is divisible by 11 11 ; etc.

Joshua Lowrance - 2 years, 1 month ago
Vinod Kumar
Dec 10, 2018

Wrote and checked with Python3 program, 6 and 9 are the exceptions.

Answer=2

Of course, tested only for prime numbers between 1 and 10001.

For instance, 2 and 3 are within first 10.

Remaining show a steady pattern with exception of 6 and 9. To be sure, I was only verifying my guess of 6 and 9. Therefore, answer is 2.

It is a small program with two functions, primegenerator and digitsum and one driver for testing in a specified range.

Program below Python3 Program - Print digit sum of Prime Numbers

def digsum(n):

if(n==0):

    return 0

if(n%9==0):

    return 9

else:

    return (n%9)

print("Enter 'x' for exit.");

print("Enter starting and ending number: ");

start = input();

if start == 'x':

exit();

else:

end = input();

lower_number = int(start);

upper_number = int(end);

print("\nPrime Numbers between the given range:")

for num in range(lower_number, upper_number+1):

        if num>1:

            for i in range(2, num):

                if(num%i)==0:

                    break;

            else:

                print(num,digsum(num));

sample output between 1801 and 2001

Enter 'x' for exit.

Enter starting and ending number:

1801

2001

Prime Numbers between the given range:

1801 1

1811 2

1823 5

1831 4

1847 2

1861 7

1867 4

1871 8

1873 1

1877 5

1879 7

1889 8

1901 2

1907 8

1913 5

1931 5

1933 7

1949 5

1951 7

1973 2

1979 8

1987 7

1993 4

1997 8

1999 1

There is a very close relationship between the modulo 9 equivalents of numbers and their digit sums

In mathematical terminology there is an isomorphism between digit sum arithmetic and modular 9 arithmetic

Use the following Wolfram Alpha script to print digit sum of first 200 prime numbers

Table[Prime[n],{n,200}] mod 9

{2, 3, 5, 7, 2, 4, 8, 1, 5, 2, 4, 1, 5, 7, 2, 8, 5, 7, 4, 8, 1, 7, 2, 8, 7, 2, 4, 8, 1, 5, 1, 5, 2, 4, 5, 7, 4, 1, 5, 2, 8, 1, 2, 4, 8, 1, 4, 7, 2, 4, 8, 5, 7, 8, 5, 2, 8, 1, 7, 2, 4, 5, 1, 5, 7, 2, 7, 4, 5, 7, 2, 8, 7, 4, 1, 5, 2, 1, 5, 4, 5, 7, 8, 1, 7, 2, 8, 7, 2, 4, 8, 2, 1, 5, 4, 8, 5, 8, 1, 1, 7, 8, 5, 2, 4, 1, 2, 8, 5, 7, 4, 1, 5, 7, 1, 2, 4, 8, 5, 2, 4, 7, 2, 8, 7, 8, 7, 8, 7, 4, 1, 5, 4, 1, 5, 4, 8, 4, 5, 8, 1, 2, 4, 8, 1, 2, 7, 2, 4, 8, 4, 8, 1, 5, 7, 2, 1, 2, 1, 5, 2, 8, 4, 8, 5, 2, 1, 7, 1, 5, 2, 4, 5, 7, 4, 5, 7, 8, 1, 7, 7, 2, 4, 8, 5, 2, 1, 7, 4, 8, 1, 2, 1, 2, 8, 5, 4, 7, 2, 8}

How are you able to write a program that test for all prime numbers? Doesn't that program fail to terminate?

Pi Han Goh - 2 years, 6 months ago

Log in to reply

Of course, tested only for prime numbers between 1 and 10001.

For instance, 2 and 3 are within first 10.

Remaining show a steady pattern with exception of 6 and 9. To be sure, I was only verifying my guess of 6 and 9. Therefore, answer is 2.

It is a small program with two functions, prime generator and digit sum and one driver for testing in a specified range.

Vinod Kumar - 2 years, 6 months ago

Log in to reply

Writing such a program does not solve the problem. If it turned out that there was a prime number above 10001 that had a final digit sum of either 6 or 9, your program wouldn't find it.

Your program does allow you to start to figure out if there is a pattern, but you need to work out what that pattern is and why it is there to prove your answer.

The reason for the pattern is that every number that has a final digit sum of 3, 6 or 9 is a multiple of 3, and therefore cannot be prime, with the exception of 3 itself.

Chris Sparke - 2 years, 6 months ago

Log in to reply

@Chris Sparke I have posted the program under my discussion, where, you can choose the range and analyse the results.

Vinod Kumar - 2 years, 6 months ago

What do you mean by steady pattern?

While your guess is correct, your solution does not rigorously demonstrate that the answer is 2.

Maybe there exists a prime number p > 1 0 1 0 1 0 10 p>10^{10^{10^{10}}} such that if I input it into the system, it might output 6?

Pi Han Goh - 2 years, 6 months ago

Log in to reply

@Pi Han Goh Well, in that case, the mathematics will be useless for programmers.

Vinod Kumar - 2 years, 6 months ago

The number 11 is a prime number. The sum of its digits is 2 isn't ? so 2 can be an output

Rene Valdes Asiain - 2 years, 6 months ago

Log in to reply

2 and 11 both are prime numbers with digit sum of 2. Therefore, 2 is not in the exception category like 6 & 9. Output category is 1, 2, 3, 4, 5, 7, 8.

Vinod Kumar - 2 years, 6 months ago
  • If the digital sum of a number is 3 , 6, or 9 then the original number is divisible by 3.
  • 3 is the only prime number divisible by 3
  • Therefore the digital sum of any prime number can never be a 6 or 9, so the solution is 2
Daria Bobu
Dec 14, 2018

I have a question. What about 0? It can not result from any combination, but it was not counted. So it should have been 0,6,9 all three. And the answer should be 3. Maybe I’m wrong but I would like to know :) thanks

Question is about Positive intiger, ie greater than zero

Pvrrafi pvr - 2 years, 5 months ago
Rajat Ranjan Jha
Dec 16, 2018

Let's start with the first possible output, 1. Then, 19 gives digit sum 1; 2, 3, 5, 7 are themselves prime, so at least one number gives them as digit sum, i.e. the digit themselves. Now, 13 has digit sum 4; No.s with digit sum 6 and 9 can never be prime, as they are digit sum divisible by 3, so, their no.s must be divisible by 3. And, 17 has digit sum 8. Hence, 6 and 9 are two impossible outputs of the program.

Joshua Lowrance's solution says "Therefore, no number can have a digital root of 6 or 9.", but it should say "Therefore, no PRIME number can have a digital root of 6 or 9."

John Rasor - 2 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...