Sort by

recency

|

38 Discussions

|

  • + 0 comments

    Prime digit sums play an interesting role in number theory, especially when dealing with sums of prime digits in sequences. If you're exploring similar calculations, this tool might be useful: https://aliciacalculadora.net/

  • + 0 comments

    Can you please elaborate the answer?

  • + 0 comments

    What is wrong with the solution:

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    #
    # Complete the 'primeDigitSums' function below.
    #
    # The function is expected to return an INTEGER.
    # The function accepts INTEGER n as parameter.
    #
    _arr = []
    _sum3=set()
    _sum4=set()
    _sum5=set()
    _primes=[]
    
    def _is_prime_trial_division(n):   
        return int(n) in _sum3 or int(n) in _sum4 or int(n) in _sum5
        
    def _build_prime_trial_division():
        for i in range(0, 10**3-1):
            if _primes[sum([int(x) for x in list(str(i))])]:
                _sum3.add(i)
        for i in _sum3:
            for j in range(10):
                if _primes[i+j]:
                    _sum4.add(int(str(i)+str(j)))
        for i in _sum4:
            for j in range(10):
                if _primes[i+j]:
                    _sum5.add(int(str(i)+str(j)))
    
        
    
    def _build_sieve_of_eratosthenes(limit):
        global _primes
        _primes = [True] * (limit + 1)
        p = 2
        while p * p <= limit:
            if _primes[p]:
                for i in range(p * p, limit + 1, p):
                    _primes[i] = False
            p += 1
        
        
    def _prime_sum(x):
        x=str(x)
        for i in range(len(x)-5):
            if not _is_prime_trial_division(x[i: i+5]):
                return False
        for i in range(len(x)-4):
            if not _is_prime_trial_division(x[i: i+4]):
                return False
        for i in range(len(x)-3):
            if not _is_prime_trial_division(x[i: i+3]):
                return False
                       
        print(x)
        return True
                
                
            
    def primeDigitSums(n):
        _build_sieve_of_eratosthenes(10**5)
        _build_prime_trial_division()
    
        count=0
        for i in range(10**(n), 10**(n+1)-1):
            if _prime_sum(i):
                count+=1
     
        return count
        # Write your code here
    
    
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        q = int(input().strip())
    
        for q_itr in range(q):
            n = int(input().strip())
    
            result = primeDigitSums(n)
    
            fptr.write(str(result) + '\n')
    
        fptr.close()
    
  • + 0 comments

    Prime digit sums refer to the sum of digits in a number where each digit is a prime number (2, 3, 5, or 7). For example, in the number 237, the sum of the prime digits is 2 + 3 + 7 = 12. This concept can be useful in number theory and digital signal processing. Turn on screen reader support for accessibility, making content more readable for visually impaired users. Prime digit sums can be applied to various mathematical problems where the properties of prime numbers are relevant.

  • + 0 comments

    HackerRank has introduced the " Token Maker " a feature that allows users to generate unique tokens for coding challenges and assessments. These tokens can be used to securely share tests with others, ensuring that each participant gets a personalized experience. The Token Maker helps maintain the integrity of coding tests by preventing unauthorized access and ensuring that only intended recipients can participate.