Count all the values

Algebra Level 3

1 2 2017 , 2 2 2017 , 3 2 2017 , , 201 7 2 2017 \left \lfloor \dfrac{1^2}{2017} \right \rfloor , \, \left \lfloor \dfrac{2^2}{2017} \right \rfloor , \, \left \lfloor \dfrac{3^2}{2017} \right \rfloor , \, \ldots , \, \left \lfloor \dfrac{2017^2}{2017} \right \rfloor

How many distinct numbers are there in the list of numbers above?


Notation: \lfloor \cdot \rfloor denotes the floor function .


The answer is 1513.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

7 solutions

Pavneet Oberoi
Sep 15, 2017

Relevant wiki: Floor Function

n 2 2017 ( n 1 ) 2 2017 1 n 2 ( n 2 + 1 2 n ) 2017 1 2 n 1 2017 1 2 n 1 2017 n 1009 \begin{array} { l r l } & \frac{n^2}{2017} - \frac{(n-1)^2}{2017} &\geq 1 \\ \Leftrightarrow & \frac{n^2-(n^2+1-2n)}{2017} &\geq 1 \\ \Leftrightarrow & \frac{2n-1}{2017} &\geq 1 \\ \Leftrightarrow & 2n-1 &\geq 2017 \\ \Leftrightarrow & n &\geq 1009\\ \end{array}

From above, when n 1009 n \geq 1009 its difference of a value from its previous value is greater then 1. Therefore the floor function will have a unique value when n 1009. n \geq 1009 . The total number of values for this case is ( 2017 1009 ) + 1 = 1009. (2017-1009)+1=1009 .

Conversely, when n 1008 n \leq 1008 , then the difference between consecutive values is less than 1, hence we will obtain every integer in that range. Since 100 8 2 2017 = 503 , \left \lfloor \frac{1008^2}{2017} \right \rfloor = 503 , each value from 0 to 503 will be obtained so there are 504 unique values.

This means the total number of unique values is 1009 + 504 = 1513. 1009+504=1513.

Moderator note:

Note, essentially there are two types of counting: for the numbers greater or equal to 1009, the solution notes each term is unique, so is counting the number of terms in the sequence in that span .

For the numbers less than or equal to 1008, the solution looks at the actual values of the floors instead, and notes every value from 0 to 503 must be included, so is counting based on the actual values of the terms .

Can someone please explain what the question is asking for? I'm reading the question and solutions and still not understanding how you mean "distinct numbers" in this context.

Brian Egedy - 3 years, 8 months ago

Log in to reply

Distinct numbers would be ones where none of them in the set are equal. The floor(1.4) and floor(1.5) are both 1 so they are not distinct numbers.

Jason Dyer Staff - 3 years, 8 months ago

I have cleaned up the notation in the solution for the author, and added a clarifying note.

Jason Dyer Staff - 3 years, 8 months ago

I assume that when Pavneet is using the value n, he is referring to the numerator in the series so that the series represents all floor functions [n^2/2017]. This function does not reach 1 until n = 45, reaches 2 when n = 64, reaches 3 at n = 78, and the numbers naturally get closer as n gets larger, but at n = 503, a number singled out by P., the value of the floor function is 125, since [503^2/2017] = 125.438... What I am saying is that as n increases from 1 to 503, the floor numbers from 1 to 125 are generated. Either I don't understand the problem, but the conclusion seems at variance with the result. Can't the problem be worded as to ask how many unique floor values are contained in the series as n goes from 1 to 2017? Ed Gray

Edwin Gray - 3 years, 8 months ago

Log in to reply

I believe what is being said is that for integers less than 1009, the spacing between the function being evaluated is less than one. Therefore, every number less than 100 8 2 2017 503.75 \frac{1008^2}{2017} \approx 503.75 will have at least one instance in the series. The number of integers from 0 to 503 is 504. From 1009 on, because the spacing is larger than one, every value used will produce a unique number in the series. There are 1009 numbers left for 1009-2017, so 1009 + 504 = 1513.

Bradley Treece - 3 years, 8 months ago

Could you please make it more legible? It is very hard to follow. Thanks

Puneet Sapra - 3 years, 8 months ago

To Bradlee, we need to clear up what we are referring to when we talk about integers and function. I assume that by integers, we mean the numerators in the floor function [n^2/2017].Note that this function has the value 0 until we reach n= 45, since 45^2/2017 = 1.0003966287.. It does not reach 2 until n = 64 since 64^2/2017 = 2.030738721, so you can see that the solutions start out sparse. A solution is defined whenever the function hits a new integer as we increase from 1,2,3,..... As a matter of interest, when n = 503, we have n =125 since 503^2/2017 = 125.4382747. When n = 1009, we have 1009^2/2017 = 503.75, as agreed by all; however, the solutions below this are not every integer, but are quite sparse, settling down to every other integer or so, not every integer. I think I have shown that the first 44 integers produce 0 as the value of the floor function. If I am correct, I believe the real answer if we reach an understanding what the problem is would be considerably less than that given. Someone with a computer should have a relatively easy time of it. Ed Gray

Edwin Gray - 3 years, 8 months ago

I'll add one more comment. There seems to be agreement that because numbers are have a spacing less than 1, they have different floor numbers. On the contrary, the floor number is the largest integer less than a given number. It would follow that numbers close together would all have the same floor number until the argument got large enough to produce the next highest integer for the floor number. I have already pointed out that n^2/2017 is < 1 for n < 45. Hence for 1 < n < 45, the floor number is 0 which is the largest integer less than or equal to n^2/2017. I will bore you no more. Thanks for reading. Ed Gray

Edwin Gray - 3 years, 8 months ago

Jason, I find the explanation confusing, especially for the lower part of the spectrum. The problem asks for unique floor values, and you say that for values less than 503, since the values of [n^2/2017] < 1,all should be included, but the floor value is 0 until we get to the 45th term, then becomes 1, stays there until n is in the 60's, and there are only 4 distinct floor values in the first 100 terms.. I am missing something and I apologize. In any case, keep trying. Ed Gray

Edwin Gray - 3 years, 8 months ago

Log in to reply

Suppose you have a sequence that decrements by 0.7, starting from 10: 10.0, 9.3, 8.6, 7.9, 7.2, 6.5, 5.8, 5.1, 4.4, 3.7, 3.0, 2.3, 1.6, 0.9, 0.2

Converting these into the floors 10, 9, 8,7, 6, 5, 5, 4, 3, 3, 2, 1, 0, 0 removing the duplicates: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 so all values from 10 to 0 are included.

I'm guessing your confusion might be you are removing both duplicates. We still can count a distinct value 5 from the example set, just we can't count both of them because the set won't consist solely of distinct integers any more.

Jason Dyer Staff - 3 years, 8 months ago

For a number "n", at what point does the consecutive square divided by a number "y" become at least 2y? Is it fluke or theory that it was the value rounded up from 2017/2 ? And how did he know absolutely that each number afterwards would yield at least some k*2017?

Seb Wilkes - 3 years, 8 months ago
Victor Dumbrava
Sep 25, 2017

I've written the following program in Pyth :

K2017l{m/^d2KSK

You can try it online here . Note that Pyth is a golfing language, and its aim is to make programs as short as possible.

How does it work?

K2017l{m/^d2KSK  - Full program.

K2017            - Assign 2017 to a variable K.
       m     SK  - Map over the range [1, K], with a preassigned variable d.
         ^d2     - Square d.
        /   K    - Integer division with K.
      {          - Remove duplicate elements.
     l           - Length.
                 - Print the result implicitly.

Oh my! Why do you want to solve a problem using a golfing language?

Good job, though

Agnishom Chattopadhyay - 3 years, 8 months ago

Log in to reply

Why not? :P

Victor Dumbrava - 3 years, 8 months ago
Stephen Weinberg
Sep 24, 2017

The lazy solution (python3): len(set(x*x//2017 for x in range(1, 2018)))

Explanation (also valid code):

1
2
3
4
5
6
7
8
9
# The i'th element of the sequence is implemented by f(i). "//" is integer division which is equivalent to floor(a/b)
f = lambda i: (i*i)//2017

# The full sequence is i in the range of [1, 2018)
seq = (f(i) for i in range(1, 2018))

# Finally, we need to get the number of unique numbers in the sequence. We do this by initializing a "set"
# which ignores duplicate entries.
len(set(seq))

Haha, this is a quick solution.

How would you generalise this method, though? What if the bounds were large?

Agnishom Chattopadhyay - 3 years, 8 months ago
Kim Rylund
Sep 27, 2017

2017 = 44.9 \sqrt{2017}=44.9 which means that x 2 / 2017 = 0 \lfloor x^2/2017 \rfloor=0 if 0 x 44 0\leq x\leq 44

2017 2 = 63.5 \sqrt{2017*2}=63.5 which means that x 2 / 2017 1 \lfloor x^2/2017 \rfloor\leq 1 if 0 x 63 0\leq x\leq 63 , which also means that there is 2 distinct numbersin the sequence up to x=63 (which are 0 and 1).

Now the fun part:

2017 500 = 1004.24 \sqrt{2017*500}=1004.24 and 2017 501 = 1005.24 \sqrt{2017*501}=1005.24 , this means that for x>=1005 every number in the sequence is unique.

Since 2017 500 = 1004.24 \sqrt{2017*500}=1004.24 we know there exist 500 unique numbers(including 0) for 0 x 1004 0\leq x\leq 1004

The entire sequence contains 500+2017-1004=1513 unique numbers.

We Need to be careful in our counting process; for example, the numbers 555,588,573 are not the floor of any [n^2/2017. Ed Gray]

Edwin Gray - 3 years, 8 months ago

Log in to reply

My solution try to find a value x=floor(n^2/2017) such that all x'>=x has at most one value n for which it is true(not multiple values it is the floor of), and all x'<x has at least one value n for which the formula is true (they are the floor of).

If I find that x and n, then for all values n'>n the function floor(n'^2/2017) will give a unique value. So we count all the x' which are smaller than x, because they all are the floor for some n. And we count all the n'>=n because they all generate a unique floor.

x=500, n=1004.

I hope this helps clarify how we do not count numbers which are not the floor of any n^2/2017 :)

Kim Rylund - 3 years, 8 months ago
David Stulman
Sep 26, 2017
1
2
3
4
5
count = 1
for i in range(1, 2017):
    if ((i+1)**2) // 2017 != (i**2) // 2017:
        count += 1
print(count)

1
2
denom = 2017
print len(set([float(x**2)//denom for x in range(1,denom+1)]))

1513

Michael Fitzgerald - 3 years, 3 months ago

Alternate python 2.7 two-liner

Michael Fitzgerald - 3 years, 3 months ago
Anime & Music Hd
Sep 29, 2017

One-liner in Python2.7:

print len({i**2/2017 for i in xrange(1,2018)})

Kyle T
Sep 29, 2017

Php code solution

1
2
3
4
5
6
7
8
<?php  
$a = array();  
for($i=1;$i<=2017;$i++){  
    $a[] = floor(pow($i,2)/2017);  
}  
$a = array_unique($a);  
echo count($a);  //prints 1513
?>

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...