Monday, March 9, 2020

HackWithInfy Problem | Playing With Primes

“Playing with primes”

Given an intger N.
N<=1e50
Output the no. of pairs (x,y) such that

1. 0<=x<=n
2. 0<=y<=n
3. F(x) +F(y) =Prime no.
    F(x) = sum of digits of x

Note : (x,y) and (y,x) are to be treated as same pair.

 Input 
 3

 Output 
 5

 Explaination
 5 pairs (0,2) (1,1) (0,3) (2,3)(1,2) give prime no.s.

No comments:

Post a Comment