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 9252281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:54:21+00:00 2026-06-18T10:54:21+00:00

Sorry for the poor title. I couldn’t find a better title. (Edits are welcome

  • 0

Sorry for the poor title. I couldn’t find a better title. (Edits are welcome :p )

Lets say that there is a number X=8. I know 2*2=4 so it does not contain the number 8.

EDIT: imagine a 2×2 grid … 1,2,3,4 … it does not contain 8

Now, 3*3 = 9 and we have found our winner(n=3)!

My (poor) code for this purpose

 long long int i=0; N = 8;
 while (i*i <N)
    {
        i++;
    }
    l = i; // l is to store he number "3"; say 8 is in a 3x3 grid

This is not a efficient way to calculate when N = 100000000.

What is more efficient way to get i*i that contains X ?

  • 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-06-18T10:54:23+00:00Added an answer on June 18, 2026 at 10:54 am

    Use the sqrt function from <math.h>. It’ll be a (fairly) efficient algorithm, and should run much faster than your loop. Then round up, and you have your answer.

    int find_containing_int(double x)
    {
      const double sqr = sqrt(x);
    
      return ceil(sqr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the poor title,I'm new to OOP so I don't know what is
Sorry for the poor title, but I couldn't think of another way to describe
Sorry for the poor title, I don't really know what to call this. I
I'm sorry about the title. I know it is rather poor but I wasn't
sorry for my poor English. I seached for hours but I couldn't find any
Sorry for the poor title, can't think of a succinct way of putting this..
Sorry for question but I can't find answer anywhere on internet. I couldn't find
Sorry for the lame title, my descriptive skills are poor today. In a nutshell,
Sorry for the poor title guys, but I'm whooped. I have a table as
Sorry for the poor title. Take these cases: Case 1: a = true; if

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.