I would like to find the value n satisfying following equation . How can I do it in Mathematica?
15411 == 123*Fibonacci[n] + 31*Fibonacci[n + 1]
You can use either Solve
or Reduce
if you specify an range for n
which contains the solution. The range does not have to be tight.
eqn = 15411 == 123*Fibonacci[n] + 31*Fibonacci[n + 1];
sol1 = Solve[{eqn, -50 < n < 50}, n, Integers]
(* {{n -> 11}} *)
Verifying,
eqn /. sol1[[1]]
(* True *)
Or
sol2 = Reduce[{eqn, -50 < n < 50}, n, Integers] // ToRules
(* {n -> 11} *)
(Pick[#, (eqn /. n -> # ) & /@ #] &@Range[-50, 50] )
$\endgroup$
Commented
Apr 5, 2018 at 17:56
FindInstance[ 15411 == (123*Fibonacci[n] + 31*Fibonacci[n + 1]), n, Reals]
$\endgroup$Integers
) $\endgroup$11
:FindInstance[{15411 == (123*Fibonacci[n] + 31*Fibonacci[n + 1]), 0 < n < 200000, n ∈ Integers}, n]
$\endgroup$Fibonacci
is defined on reals other than integers, so could just useFindRoot
.In[6]:= FindRoot[15411 == 123*Fibonacci[n] + 31*Fibonacci[n + 1],{n,9}] Out[6]= {n -> 11.}
$\endgroup$