A set of tiles are numbered 1-N, In one step you can remove all tiles with a square number,and than rename all the tiles,starting from 1. This is the question,
and what I found is is formula ceil((sqrt(N)-1)*2)
I tried many values still unsuccessfull of proving or disproving anything about this question,
Please Help me prove or disprove this cool formula or trick I would rather say.








hmm.. interesting
I proved it https://codeforces.me/blog/entry/145184
I had to delete that blog, so if you want that proof, just DM me.
What does the formula calculate?
No of steps needed to reach 1 tile. It’s a very classical problem and OP’s formula does seem to work.
I meant what is OP's formula?
bro you are the OP!
OP's formula, S(N) = ceil((sqrt(N) − 1) ∗ 2), calculates the number of steps required to reduce N tiles to one. This is likely an excellent approximation, but for large numbers, this approximation might lead to significant errors. Proving its valid for all N > 0 would be tough, even if it was the correct formula, due to the complexities introduced by the floor function in the recursive step.
its working for 832974932748973289
Then OP might have just stumbled on an optimal solution for this problem, assuming it hasn't been discovered yet.
bro accidentally found a conjecture *_*
Yeah, let's see if he is interested in proving it.
yes I can prove this
That's great. Do share here once done.
Fun Fact: OP is Saram_og
Muhammad-Salman already proved it
Saram, from Introduction to Number Theory, isn't this question from there? But an easier version of that one?
there are multiple intro to number theory books on Google, which one are you referring to?
Hello
bro what in the actual hell, why tf r u lying?? lol
I cant believe he made an alt account just to fricking troll someone!
I tried proving it.
lets find all intervals $$$[l_i, r_i]$$$ that for all numbers from i-th interval, we need do $$$i$$$ steps. we know that $$$l_0 r_0 = {0, 0}$$$, now we need to find next segment. its easy to understand that $$$l_{i+1} = r_i + 1$$$ so we need find only $$$r_{i+1}$$$. lets say we have X tiles, we know that we will remove exactly $$$\sqrt{X}$$$ tiles, so $$$r_{i+1} - \sqrt{r_{i+1}} = r_i$$$ here we get a formula that can be solved by the discriminant.

I wrote the code and got the following segments:
$$$0$$$ from $$$1$$$ to $$$1$$$
$$$1$$$ from $$$2$$$ to $$$2$$$
$$$2$$$ from $$$3$$$ to $$$4$$$
$$$3$$$ from $$$5$$$ to $$$6$$$
$$$4$$$ from $$$7$$$ to $$$9$$$
$$$5$$$ from $$$10$$$ to $$$12$$$
We can see that
knowing all the above, I can get the expression that you described
during my wrong calculations I got another formula (BUT IT WORKS)
genius!
cool can you share the code with me?
This works on my PC, so I guess proof by AC? I asked chatgpt to prove by induction and I think it's right, but I won't bother reading the proof carefully:
https://chatgpt.com/share/688b4d1c-84f8-8011-b237-2fd33527475b
well this is quite similar to how I proved it
This is only an approximation;
Assume we start with $$$n$$$.
$$$(\sqrt n - 1)^2 = n - 2\sqrt n + 1 \lt n - \sqrt n$$$ (the numbers left after the first step), so we remove the squares of the numbers $$$1\ldots\sqrt n$$$ and $$$1\ldots\sqrt n - 1$$$ (kind of).
So in two steps, we reach from $$$n = (\sqrt n)^2$$$ to $$$(\sqrt n - 1)^2$$$, then in another two $$$(\sqrt n - 2)^2$$$, etc.
And this gives $$$2\sqrt n$$$ steps.