login
a(n) is the smallest positive integer k such that |tan(k) - round(tan(k))| is smaller than 10^(-n), but greater than 10^(-n-1).
2

%I #24 Jul 31 2021 17:27:11

%S 11,22,1120,355,14817,286602,5117932,144316263,167004362,8984683957

%N a(n) is the smallest positive integer k such that |tan(k) - round(tan(k))| is smaller than 10^(-n), but greater than 10^(-n-1).

%C In other words, a(n) is the smallest positive integer k such that the distance between tan(k) and nearest integer to tan(k) is smaller than 10^(-n), but greater than 10^(-n-1).

%e For n=3, a(n)=1120, because 1120 is the smallest positive integer such that |tan(1120) - round(tan(1120))| = 0.0008709... < 10^(-3) and 0.0008709... > 10^(-4).

%p n := 1: for i from 2 to 10^10 do if 10^(-n - 1) < abs(evalf(tan(i)) - floor(evalf(tan(i)) + 1/2)) and abs(evalf(tan(i)) - floor(evalf(tan(i)) + 1/2)) < 10^(-n) then print(i); n := n + 1; i := 1; end if; end do;

%t Transpose[Table[Catch[Table[Table[{i, j};

%t If[10^(-i - 1) < Abs[Tan[j] - Round[Tan[j]]] &&

%t Abs[Tan[j] - Round[Tan[j]]] < 10^(-i),

%t Throw[{i, j}]], {i}], {j, 10^(i+1)}]], {i, 10}]][[-1]] (* _Bence BernĂ¡th_, Jul 07 2021 *)

%o (C++) #include <iostream>

%o #include <cmath>

%o using namespace std; int main(int argc, char** argv) {long double n=1; int q=2; for(n=1; n<=10; n++){for(int i=q; i<=100000000000; i++){long double k=tan(i); if(abs(k-round(k))<pow(10, -n)&&abs(k-round(k))>pow(10, -n-1)){cout<<i<<", "; break; }}}}

%o (PARI) a(n) = my(m); default(realprecision, 2*n); for(k=1, oo, if(10^-n > (m=abs(tan(k)-round(tan(k)))) && m > 10^(-n-1), return(k))); \\ _Jinyuan Wang_, Jun 18 2021

%Y Cf. A000209, A345328.

%K nonn,more,hard

%O 1,1

%A _Andrzej Kukla_, Jun 18 2021