What is the largest value of $k$ such that $4k + 1$ produces maximum consecutive terms which are neither primes nor perfect squares and $k$ is a natural number.
For example, at $k = 16$, we get a sequence of two consecutive terms, 65 and 69 which are neither prime nor square.
One of my friend asked me this question and I am unable to solve it. Can anybody please solve it?
As Tom already explained, you can use the factorials to obtain a sequence of composite non-squares of any length you want.
However, if you only want to go up to a certain bound, your best bet might be to choose the largest $k$ less than the bound such that $k - 1$ is divisible by two consecutive integers.
For example, 9900 is divisible by 99 and 100. Then $4 \times 9900 + 1 =$ $39601 = 199^2$. Therefore, with $k > 9900$, we can be certain that the next $k$ that gives a square for $4k + 1$ is $k = 10100$, which leads to $201^2 = 40401$.
But any of those other $k$ between 9900 and 10100 could give a prime, as far as we know right now. When $k \equiv 1 \pmod 5$ (it ends in 1 or 6 in base 10) and $k > 1$, we can rest assured $4k + 1$ is a multiple of 5, as is, for example, 39605. And we get lucky with 36909 being a multiple of 3.
I give Mathematica the command
Select[Range[9890, 10100], PrimeQ[4# + 1] &]and it answers that $k = 9927$ plugged into $4k + 1$ gives a prime, as well as a bunch of other numbers (this works in Wolfram Alpha, too).Applying
Differences[%](you'll have to be a bit more verbose in Wolfram Alpha, but not necessarily with too much typing) we see the largest difference is 32, but that includes the square 39601 produced by $k = 9900$.So the longest sequence up to your stated bound of 10000 might indeed be of length 26, but I don't feel like checking $k < 9000$. Not that it would be too difficult in Mathematica or even Wolfram Alpha, it just takes a bit more mental effort than I'm willing to expend on this problem.