Thanks to @Dennis for -2 bytes!
f=lambda n,i=1:n and-~f(n-(~-7**i%i**2<1),i+1)
A one-indexed recursive function that takes input via argument and returns the result.
Try it online! (Recursion limit increased to allow the final test case to run)
How it works
n is the desired index, and
i is the counting variable.
True (equivalent to
7^i - 1, and
False (equivalent to
0) otherwise. Each time the function is called, the result of the expression is subtracted from
n each time a hit is found;
i is also incremented.
The short-circuiting behaviour of
and means that when
0 is returned; this is the base case. Once this is reached, recursion stops, and the current value of
i is returned by the original function call. Rather than explicitly using
i, this is done using the fact that for each function call, an increment has been performed using the
-~ in front of the call; incrementing
i times gives
i, as required.