Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7494803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:47:08+00:00 2026-05-29T17:47:08+00:00

Possible Duplicate: Algorithm to find Lucky Numbers I came across this question.A number is

  • 0

Possible Duplicate:
Algorithm to find Lucky Numbers

I came across this question.A number is called lucky if the sum of its digits, as well as the sum of the squares of its digits is a prime number. How many numbers between A and B are lucky? 1 <= A <= B <= 10^18.

I tried this,
First I generated all possible primes between 1 and the number that could be resulted by summing the squares (81 *18 = 1458).[Note: I used sieve of Atkin’s approach for prime number generation].
And then verifying each number’s digit sum and digit square sum is in the list of primes, if so it is lucky otherwise not. But this is very very slow. Is there any better way of solving?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:47:12+00:00Added an answer on May 29, 2026 at 5:47 pm

    Look at my well-explained solution here: Algorithm to find Lucky Numbers (please note – your question was a duplicate of this one).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Help with algorithm problem from SPOJ Came across this interview question. Given
Possible Duplicate: Easy interview question got harder: given numbers 1..100, find the missing number(s)
Possible Duplicate: Algorithm to find minimum number of weighings required to find defective ball
Possible Duplicate: Find the maximum interval sum in a list of real numbers. I
Possible Duplicate: Quickest way to find missing number in an array of numbers Input:
Possible Duplicate: substring algorithm Given two strings, A and B, how to find the
Possible Duplicate: Solution to a recursive problem (code kata) give an algorithm to find
Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit
Possible Duplicate: Linked list interview question This is an interview question for which I
Possible Duplicate: Learning efficient algorithms I recently came across an problem that was solved

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.