# Number of functions satisfying $lcm(f(n), n) - hcf(f(n), n)<5$? [duplicate]

How many functions f:N→N satisfy - $$lcm(f(n), n) - hcf(f(n), n)<5?$$

$$Attempt$$

At first I tried to use the property that

LCM*HCF=Product of the two numbers

Hence I got $$lcm.hcf=n.f(n)$$

And the other given relation in the question.

But, after this I was not able to proceed further.

Any hints/suggestions?

## marked as duplicate by metamorphy, Community♦Jun 5 at 6:25

Hint: Suppose $$f(n). Then $$\gcd(f(n),n)\leq n/2$$ and $$\operatorname{lcm}(f(n),n)\geq n$$, so $$\operatorname{lcm}(f(n),n)-\gcd(f(n),n)\geq n/2$$. Similarly for $$f(n)>n$$. So you only need to check the possible $$f(n)$$ for a few values of $$n$$.
• Because it has to be a divisor of $n$, and $n$ itself is ruled out because $f(n)<n$. The largest divisor possible of $n$ apart from $n$ itself is $n/2$. – user10354138 Jun 5 at 6:34