3

Let $F_n$ denote the $n$-th Fibonacci number. I am interested in the sequence $$a(k, n)=\left | \left \{0 \leq m \leq n: \frac{F_m}{k} \; \text{is a perfect square} \right \} \right |,$$ where $|\cdot|$ denotes the cardinality of a set.

For example, $a(1, 100) = 4$ since there are only four perfect squares among the first $n=100$ Fibonnaci numbers: $F_0=0$, $F_1=1$, $F_2=1$ and $F_{12}=144$.

How can I write a code to calculate $a(k, n)$?

Domen
  • 23,608
  • 1
  • 27
  • 45
user227351
  • 105
  • 11

1 Answers1

4

You did not give an example. Is this what you want?

Using Michael E2 code to check for perfect square from Fastest square number test

ClearAll[a,sQ];
sQ[n_]:=FractionalPart@Sqrt[n+0``1]==0;
a[k_Integer,n_Integer?Positive]:=Table[f=Fibonacci[m]/k; If[sQ[f],m,Nothing],{m,0,n}];
a[1,100]

Mathematica graphics

Length[%]
(*4*)
Nasser
  • 143,286
  • 11
  • 154
  • 359