OFFSET
1,2
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000 (terms 1..1000 from Andrew Howroyd)
FORMULA
If n is odd with prime factorization p1^j1*p2^j2*...pk^jk then f(n)=p1^(j1 mod 2)*p2^(j2 mod 2)*... If n is even then f(n)=2^(2-(j1 mod 2))*p2^(j2 mod 2)*... f(n)=n whenever n is squarefree or n/2 is squarefree. (Christian G. Bower)
Multiplicative with a(p^e) = p if e is odd, 4 if p=2 and e is even, 1 if p>2 and e is even. - Vladeta Jovovic, May 15 2003
Sum_{k=1..n} a(k) ~ c * n^2, where c = 3*Pi^2/80 = 0.3701101... . - Amiram Eldar, Oct 27 2022
MATHEMATICA
Table[k = 1; While[Nand @@ IntegerQ /@ {(n + k)/2, Sqrt[n*k]}, k++]; k, {n, 78}] (* Jayanta Basu, Jul 14 2013 *)
f[p_, e_] := If[OddQ[e], p, If[p == 2, 4, 1]]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* Amiram Eldar, Sep 09 2020 *)
PROG
(PARI) a(n)={for(k=1, n, if((n+k)%2==0 && issquare(n*k), return(k)))} \\ Andrew Howroyd, Feb 12 2018
(PARI) a(n) = {my(f = factor(n)); prod(i = 1, #f~, if(f[i, 2]%2, f[i, 1], if(f[i, 1]==2, 4, 1))); } \\ Amiram Eldar, Oct 27 2022
CROSSREFS
KEYWORD
nonn,easy,mult
AUTHOR
EXTENSIONS
More terms from Vladeta Jovovic, May 15 2003
STATUS
approved