We define n ♡ recursively as follows. 1 ♡ = 1 ; n ♡ = ( ( n − 1 ) ♡ ) ⋅ n + 1 Find the largest n < 1 0 0 0 such that the last two digits of n ♡ are zeroes.
Details and assumptions
Just to make it clear: unlike "n-factorial," "n-heart" is NOT an official mathematical terminology.
Clarification: There is no restriction / requirements on the third last digit.
Clarification: We can calculate that 2 ♡ = ( 1 ♡ ) ⋅ 2 + 1 = 1 ⋅ 2 + 1 = 3 and 3 ♡ = ( 2 ♡ ) ⋅ 3 + 1 = 3 ⋅ 3 + 1 = 1 0 .
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.
Great writeup!
The fact that it's not immediately periodic means that we have to be very careful with the arguments presented.
Though, you should be careful with your final claim. Remember that you needed to use the fact that n ≥ 4 (first claim) and n ≥ 1 5 (second claim), hence your result only holds for n ≥ 1 5 . In particular, f 7 ≡ 0 ( m o d 1 0 0 ) .
Log in to reply
Yes sir, sorry for that. The final claim should be:
> To conclude,
1
0
0
∣
n
♡
,
n
≥
1
5
⟺
n
≡
7
/
1
9
(
m
o
d
1
0
0
)
(I believe by f n you mean n ♡ ) But note that since we are interested in the largest value of n in the range [ 1 , 1 0 0 0 ] and there exist solutions for n > 1 5 , this doesn't change the answer (which is why I got the correct answer as the result).
I messed up in the induction step for proving k ♡ ≡ ( k + 2 5 ) ♡ ( m o d 2 5 ) ⟹ ( k + 1 ) ♡ ≡ ( k + 2 6 ) ♡ ( m o d 2 5 ) , where I used n ≥ 1 5 , n ≥ 2 0 and n ≥ 4 5 interchangeably. Can you please correct it?
Log in to reply
I've changed it all to n ≥ 1 5 (though your statements still hold true).
As a side note, it is true for n ≥ 1 0 , so that would be the better induction hypothesis, since it covers all cases and people won't be wondering "Why did he leave out 10, 11, 12, 13, 14".
Log in to reply
@Calvin Lin – Oh, so sorry for that. The periodicity indeed occurs after n = 1 0 , but I didn't notice this. I had to go through unnecessary case checking for 5 numbers.
Typo: Note that 1 5 ♡ ≡ 4 0 ♡ ( m o d 2 5 ) , which has been used in our base case. Our assertion is in fact true for all n ≥ 1 5 .
I'm going to use f n instead of n-heart , not sure how to write the heart :)
Firstly let's have a non-recursive definition for f n : f n = i = 1 ∑ n i ! n !
We can readily check that this satisfies the definition of n-heart.
Lemma: f n + k ≡ ( f n + n ! ) m o d k
Proof: We have f n + k = i = 1 ∑ n + k i ! ( n + k ) ! All terms with i < k are clearly ≡ 0 m o d k . So, letting j = i − k , we get f n + k ≡ j = 0 ∑ n j ! n ! m o d k ≡ j = 1 ∑ n j ! n ! + n ! ≡ f n + n !
Now, we need to solve f n ≡ 0 m o d 1 0 0 . By the Chinese Remainder Theorem we can solve this in two parts: f n ≡ 0 m o d 4 and f n ≡ 0 m o d 2 5 , since 4 and 2 5 are coprime.
If f n ≡ 0 m o d 4 then repeated application of the lemma tells us that f n ≡ f n m o d 4 + n ! m o d 4 . So we just need to compute f n + n ! for n = 1 , 2 , 3 , 4 (I choose this range to avoid using f 0 ), and we find: f 1 + 1 ! f 2 + 2 ! f 3 + 3 ! f 4 + 4 ! = 2 = 5 = 1 6 = 6 5
So we must have n ≡ 3 m o d 4 .
We can solve f n + n ! ≡ 0 m o d 2 5 in the same way. I did this by brute force, although it is not particularly brute considering that you can compute f n m o d 2 5 up to f 2 5 easily just by only keeping track of the last two digits; and since 1 0 ! ≡ 0 m o d 2 5 we don't need to worry about n ! beyond the step f 9 + 9 ! .
It turns out that f 7 + 7 ! ≡ 0 m o d 2 5 , and f 1 9 + 1 9 ! ≡ 0 m o d 2 5 , and no other solutions. So we have n ≡ 7 m o d 2 5 or n ≡ 1 9 m o d 2 5 .
So we have f n ≡ 0 m o d 1 0 0 if and only if n ≡ 7 or 1 9 m o d 2 5 n ≡ 3 m o d 4
Combining these two conditions gives n ≡ 7 or 1 9 m o d 1 0 0 , so the biggest solution under 1 0 0 0 is 9 1 9 .
You can use
\heartsuit
to type
♡
. I, however, pasted it directly from the problem statement. :)
Interesting observation.
However, note that f 7 ≡ 0 ( m o d 1 0 0 ) which contradicts your final claim. There is a slight mistake in your logic that was used to arrive at the final step of
we have f n ≡ 0 ( m o d 1 0 0 ) if and only if n ≡ 7 , 1 9 ( m o d 2 5 ) and n ≡ 3 ( m o d 4 ) .
Log in to reply
Re. f 7 , yes, I should have qualified the final few steps with n ≥ 1 0 , i.e. the range where f n + n ! ≡ f n . Thanks for putting in my correcting edit also. If there is another mistake I don't see it yet but hopefully someone can fill me in :)
Log in to reply
Can you explain where / how you used the condition that
n
≥
1
0
? It doesn't seem to be stated anywhere. Further note that if
n
≥
1
0
is required in your lemma, then you need to do calculations of
f
1
0
to
f
3
4
, instead of just up to
f
2
5
.
The periodicity does happen after
n
=
1
0
, so adding in this detail will greatly help towards establishing the validity of your proof.
In the above comment, do you mean f n + n ! ≡ f n + k (final subscript)?
I just corrected 2 instances of ( m o d 1 0 0 ) into ( m o d 2 5 ) in the earlier paragraph. Let me know if you would prefer for them to remain as 100.
Log in to reply
@Calvin Lin – f n + n ! m o d k is actually periodic with period k , right from n = 1 .My proof actually shows that f n + n ! ≡ 0 m o d 1 0 0 iff n ≡ 7 , 1 9 m o d 1 0 0 . And then we use the fact that n ! ≡ 0 m o d 1 0 0 if n ≥ 1 0 to show that if n ≥ 1 0 then f n ≡ f n + n ! .
Just out of curiosity, did the last solution get deleted? (the one with check 7 and 9 and 17 and 19)
Log in to reply
We have removed a particular individual for behavior unbecoming of the Brilliant community. As a result, we have reversed some of his actions, to rectify the situation. This led to the solution being deleted.
Yes. Probably because it was incomplete, yet rose to the top with the most number of upvotes.
Could you explain the repeated application of the lemma portion. I'm not quite sure how you got from f n = 0 (mod 4) to f n = f_(n mod 4) + n! (mod 4)
Log in to reply
For example, the lemma tells us f 1 5 ≡ f 1 1 + n ! ≡ f 1 1 m o d 4 , because n ! ≡ 0 m o d 4 as long as n ≥ 4 . Then the lemma says f 1 1 ≡ f 7 m o d 4 , and again, f 7 ≡ f 3 + 3 ! m o d 4 .
I did it the same. Great work!
Log in to reply
If you did the same, can you figure out where the mistake is?
Minor correction, the line "It turns out..." should read "It turns out that f 7 + 7 ! ≡ 0 m o d 2 5 and f 1 9 + 1 9 ! ≡ 0 m o d 2 5 , and no other solutions", although they also happen to be ≡ 0 m o d 1 0 0 .
[Note: You might need to scroll right and left to view the full solution.]
If the last two digits are zeroes, this means that n ♡ is congruent to 0 mod 25 and mod 4
Carefully writing out the congruences of n ♡ modulo 25,
n n ( m o d 2 5 ) n ♡ ( m o d 2 5 ) n n ( m o d 2 5 ) n ♡ ( m o d 2 5 ) 1 1 1 2 6 1 2 2 2 3 2 7 2 5 3 3 1 0 2 8 3 1 6 4 4 1 6 2 9 4 1 5 5 5 6 3 0 5 1 6 6 1 2 3 1 6 7 7 7 1 0 3 2 7 0 8 8 6 3 3 8 1 9 9 5 3 4 9 1 0 1 0 1 0 1 3 5 1 0 1 1 1 1 1 1 2 3 6 1 1 1 2 1 2 1 2 2 0 3 7 1 2 2 0 1 3 1 3 1 1 3 8 1 3 1 1 1 4 1 4 5 3 9 1 4 5 1 5 1 5 1 4 0 1 5 1 1 6 1 6 1 7 4 1 1 6 1 7 1 7 1 7 1 5 4 2 1 7 1 5 1 8 1 8 2 1 4 3 1 8 2 1 1 9 1 9 0 4 4 1 9 0 2 0 2 0 1 4 5 2 0 1 2 1 2 1 2 2 2 2 2 2 1 0 2 3 2 3 6 2 4 2 4 2 0 2 5 0 1
First observe that n ♡ ≡ ( n + 2 5 ) ♡ ( m o d 2 5 ) for all n ≥ 1 5 . We will prove this by induction.
Base case: We have 1 5 ♡ ≡ 1 ≡ 4 0 ♡ ( m o d 2 5 ) .
Induction step : If k ♡ ≡ ( k + 2 5 ) ♡ ( m o d 2 5 ) , then ( k + 1 ) ♡ ≡ ( k ♡ ) × ( k + 1 ) + 1 ≡ ( k + 2 5 ) ♡ × ( k + 1 + 2 5 ) + 1 ≡ ( k + 2 6 ) ♡ ( m o d 2 5 ) . Hence done.
Thus, for n ≥ 1 5 , we know that n ♡ ≡ 0 ( m o d 2 5 ) if and only if n ≡ 7 , 1 9 ( m o d 2 5 ) (check the above table).
For modulo 4, a similar observation holds. The congruences are:
n n ( m o d 4 ) n ♡ ( m o d 4 ) 1 1 1 2 2 3 3 3 2 4 0 1 5 1 2 6 2 1 7 3 0 8 0 1 9 1 2 1 0 2 1 1 1 3 0 1 2 0 1
We can similarly show that for n ≥ 4 , n ♡ ≡ ( n + 4 ) ♡ ( m o d 4 ) , and that n ♡ ≡ 0 ( m o d 4 ) if and only if n ≡ 3 ( m o d 4 ) .
Combining the above using Chinese Remainder Theorem, we know that for n ≥ 1 5 , n ♡ ≡ 0 ( m o d 1 0 0 ) if and only if n ≡ 7 , 1 9 ( m o d 1 0 0 ) . Hence, the largest possible solution is 919.
[Edits for clarity. Latex edits - Calvin]
Common mistakes
The pattern is not immediately periodic.
Not getting both cases when taking modulo 25.
Matt notes that n ♡ ≡ 1 ! n ! + 2 ! n ! + … + n ! n ! . However, there isn't an easier way to deal with this summation. This problem would arguably be harder if this definition of n ♡ was given instead.
Problem Loading...
Note Loading...
Set Loading...
We have to find a n such that 1 0 0 ∣ n ♡ . Note that 1 0 0 ∣ n ♡ ⟺ 4 ∣ n ♡ and 2 5 ∣ n ♡ Let's first try to find the set of positive integers n such that n ♡ ≡ 0 ( m o d 4 ) . To do this, let's write down the first few residues of n ♡ ( m o d 4 ) :
Here's the link in case the image doesn't load:http://s8.postimg.org/iob62zp6d/Untitled.png
In the table above, note that 4 ♡ ≡ 8 ♡ ( m o d 4 ) . We shall now prove by induction that for all n ≥ 4 , n ♡ ≡ ( n + 4 ) ♡ ( m o d 4 ) . The base case n = 4 has already been shown. Assume our assertion is true for some k ≥ 4 , so k ♡ ≡ ( k + 4 ) ♡ ( m o d 4 ) . Then, note that ( k + 1 ) ♡ ≡ ( k + 1 ) × k ♡ + 1 ( m o d 4 ) ≡ ( k + 1 ) × ( k + 4 ) ♡ + 4 × ( k + 4 ) ♡ + 1 ( m o d 4 ) ≡ ( k + 5 ) × ( k + 4 ) ♡ + 1 ≡ ( k + 5 ) ♡ ( m o d 4 ) This completes our induction step, and hence our claim is true for all n ≥ 4 . Thus, the residues of n ♡ ( m o d 4 ) become periodic with periodicity 4 . From the table above, we have 7 ♡ ≡ 0 ( m o d 4 ) , so for all n ≥ 4 , n ♡ ≡ 0 ( m o d 4 ) ⟺ n ≡ 7 ≡ 3 ( m o d 4 ) .
Similarly, we calculate the first 4 0 residues of n ♡ ( m o d 2 5 ) :
Here's the link in case the image doesn't load:http://s11.postimg.org/vb7ee4ur7/Untitled.png
Here's the link in case the image doesn't load:http://s15.postimg.org/3pedf06aj/Untitled.png
Note that 1 5 ♡ ≡ 4 5 ♡ ( m o d 2 5 ) . Similarly, we shall prove by induction that for all n ≥ 1 5 , n ♡ ≡ ( n + 2 5 ) ♡ ( m o d 2 5 ) . The base case n = 1 5 has already been shown. Assume our assertion is true for some k ≥ 1 5 , so k ♡ ≡ ( k + 2 5 ) ♡ ( m o d 2 5 ) . Then, note that ( k + 1 ) ♡ ≡ ( k + 1 ) × k ♡ + 1 ( m o d 2 5 ) ≡ ( k + 1 ) × ( k + 2 5 ) ♡ + 2 5 × ( k + 2 5 ) ♡ + 1 ( m o d 2 5 ) ≡ ( k + 2 6 ) × ( k + 2 5 ) ♡ + 1 ≡ ( k + 2 6 ) ♡ ( m o d 2 5 ) This completes the induction step, and hence our claim is true for all n ≥ 1 5 . Thus, the residues of n ♡ ( m o d 2 5 ) become periodic with periodicity 2 5 . From the table above, note that n ♡ is zero for n = 3 2 and n = 4 4 . Hence, for all n ≥ 1 5 , 2 5 ∣ n ♡ ⟺ n ≡ 3 2 / 4 4 ( m o d 2 5 ) ⟹ n ≡ 7 / 1 9 ( m o d 2 5 ) .
Solving the congruencies n ≡ 7 ( m o d 2 5 ) , n ≡ 3 ( m o d 4 ) by CRT, we get n ≡ 7 ( m o d 1 0 0 ) .
Again, solving the congruencies n ≡ 7 ( m o d 2 5 ) , n ≡ 3 ( m o d 4 ) by CRT, we get n ≡ 1 9 ( m o d 1 0 0 ) .
To conclude, 1 0 0 ∣ n ♡ ⟺ n ≡ 7 / 1 9 ( m o d 1 0 0 ) . The largest number ≡ 7 ( m o d 1 0 0 ) in the range [ 1 , 1 0 0 0 ] is 9 0 7 , and the largest number ≡ 1 9 ( m o d 1 0 0 ) in the range [ 1 , 1 0 0 0 ] is 9 1 9 . Our desired answer will be 9 1 9 .