Post Reply 
challenge - prime numbers where sum of squared digits of prime number is also prime
01-05-2018, 02:02 PM (This post was last modified: 01-05-2018 03:54 PM by Didier Lachieze.)
Post: #3
RE: challenge - prime numbers where sum of squared digits of prime number is prime
A quick HP Prime program providing the prime numbers between N & M fitting the requirement:

Code:
EXPORT PrCh(N,M)
BEGIN
  LOCAL n:=N-1,res:={};
  WHILE n<M DO
    n:=nextprime(n);
    IF isprime(ΣLIST((ASC(STRING(n))-48)^2)) THEN PRINT(n); res(0):=n; END;
  END;
  RETURN res;
END;

Call it with e.g. SIZE(PrCh(1,1000)) to know for how many primes less than 1000 the sum of squared digits of the number is prime.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: challenge - prime numbers where sum of squared digits of prime number is prime - Didier Lachieze - 01-05-2018 02:02 PM



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