Expressing a number as a finite sum of terms $a_k/k!$ The original problem is as  - Suppose $a_2,a_3,a_4, \cdots a_7$  are integers such that 
$$\frac{5}{7}=\sum_{k=2}^7 \frac{a_k}{k!}$$
where $0 \le a_j < j$ for $j=2,3,4,5,6,7$
Then find $a_2+a_3+ \dots + a_7$
This is a problem which I am unable to solve . Please help me here and also tell me about generalization of this problem . (It is OK if the solution if beyond the reach of high school students).
I  guess how to approach problems like
$$\frac{m}{n}= \sum_{k=p}^q \frac{a_k}{k!}$$ for $m,n,p,q \in \mathbb{N}$ 
for same question and condition
 A: Gerry Myerson has given the slick approach using modular arithmetic in the comments. There is also a more elementary approach. Suppose that the equation
$$\frac{p}q=\sum_{k=m}^n\frac{a_k}{k!}$$
has a solution in non-negative integers $a_k$ such that $a_k<k$ for $k=m,\ldots,n$. Note that
$$\sum_{k=m+1}^n\frac{k-1}{k!}=\sum_{k=m}^{n-1}\frac1{k!}-\sum_{k=m+1}^n\frac1{k!}=\frac1{m!}-\frac1{n!}<\frac1{m!}\;;$$
thus, we must set
$$a_m=\max\left\{\ell<m:\frac{\ell}{m!}\le\frac{p}q\right\}\;:$$
any larger value is clearly too large, and any smaller value leaves 
$$\frac{p}q-\frac{a_m}{m!}>\frac1{m!}>\sum_{k=m+1}^n\frac{k-1}{k!}\;,$$
the maximum possible value of the sum of the remaining terms. At this point we can replace the original problem by 
$$\frac{p}q-\frac{a_m}{m!}=\sum_{k=m+1}^n\frac{a_k}{k!}$$
and use exactly the same approach to find $a_{m+1}$. Continuing in this fashion, we find successively $a_m,a_{m+1},\ldots,a_n$ without guesswork at any stage. (This is in fact a greedy algorithm.)
