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

  • Home
  • SEARCH
  • 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 395607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:28:15+00:00 2026-05-12T16:28:15+00:00

When solving an interview question Question A six digit number need to be found

  • 0

When solving an interview question

Question

A six digit number need to be found in such a manner when it is multiplied by an integer between 2 and 9 gives the original six digit number when its digits are reversed.

Example:

Suppose I multiply 219978 * 4 i get 879912 ,when reverse 879912 I will get 219978 back.


I solved it using

for (long l = 100000; l < 999999; l++)
{
 var num = l.ToString();

for (int i = 3; i < 9; i++)
{
  var mul = l * i;
  string str = mul.ToString();
  char[] splitDigits = str.ToCharArray();
  string reversedDigit =
  new  string(splitDigits.Reverse().ToArray());

  if (reversedDigit.CompareTo(num) == 0)
    {
      Console.WriteLine("{0} * {1}= {2},
       when multiplied {3} ", num, i, mul,reversedDigit);

    }

 }
}


The original task was to solve it using linq.
I have bit confusion in handling temp calculations for example

when i use

   var = from l in Enumerable.Range(100000,999999)
         from i in Enumerable.Range(3,9)

What is the way to handle temporary calculations like var num = l.ToString(),etc in linq.It confused me a lot to finish it in Linq.Help is appreciated.

  • 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-12T16:28:15+00:00Added an answer on May 12, 2026 at 4:28 pm

    You want let…

        // NOTE: buggy; see below
        var qry =  from l in Enumerable.Range(100000, 999999)
                   from i in Enumerable.Range(3, 9)
                   let s = l.ToString()
                   let t = (l * i).ToString()
                   where s.Reverse().SequenceEqual(t)
                   select new { l, i };
    
        var a = qry.First();
        Console.WriteLine("an answer...");
        Console.WriteLine("{0} x {1} = {2}", a.l, a.i, a.l * a.i);
    
        Console.WriteLine("all answers...");
        foreach (var row in qry)
        {
            Console.WriteLine("{0} x {1} = {2}", row.l, row.i, row.l * row.i);
        }
    

    with first answer (note the inclusion of 9 is taken from your original version of the code, but it may be desirable to use Range(3,8) instead):

    109989 x 9 = 989901
    

    Optimised version (and correct range):

        var qry =  from l in Enumerable.Range(100000, 999999 - 100000)
                   let s = l.ToString()
                   let sReversed = new string(s.Reverse().ToArray())
                   let wanted = int.Parse(sReversed)
                   from i in Enumerable.Range(3, 8 - 3) 
                   where l * i == wanted
                   select new { l, i };
    

    This reduces the number of strings created, uses integer equality, and correctly uses the range (the second parameter to Range is the count, not the end).

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

Sidebar

Ask A Question

Stats

  • Questions 197k
  • Answers 197k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From the question I assume you have some developers (probably,… May 12, 2026 at 7:28 pm
  • Editorial Team
    Editorial Team added an answer You can just use string.split string str = "John Adams";… May 12, 2026 at 7:28 pm
  • Editorial Team
    Editorial Team added an answer Each ajax request is going to have overhead associated with… May 12, 2026 at 7:28 pm

Related Questions

Someone asked me a question via e-mail about integer partitions the other day (as
I'm getting an error message when I try to build my project in eclipse:
There are times when it makes sense to force an end of any edits
We've run into an interesting situation that needs solving, and my searches have turned
What are your criteria or things that you consider when you are an early

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.