How to compute the ring of all $f\in K[X]$ with $f(\mathcal{O}_K)\subseteq \mathcal{O}_K$? Let $K$ be a number field, $\mathcal{O}_K$ the ring of integers of $K$, and $A\subseteq K[X]$ the ring of all polynomials $f\in K[X]$ with $f(\mathcal{O}_K)\subseteq\mathcal{O}_K$. It is obvious that $\mathcal{O}_K[X]\subseteq A\subseteq K[X]$, but we can find better bounds.
Define a sequence of polynomials $\{f_n\}_{n\ge 0}$ in $\mathbb{Z}[X]$ by $f_0=1$ and $f_{n+1}=(X-n-1)f_n$. For each prime $\mathfrak{p}\mid (p)$ of $\mathcal{O}_K$, define an ideal $I_n:=\langle f_n(\mathcal{O}_K)\rangle$
For all $n$, let $\lambda_n\in\mathcal{O}_K$ with $I_n\subseteq (\lambda_n)$, then if I'm not mistaken
$$
\bigoplus_{n\ge 0}\frac{f_n}{\lambda_n}\cdot \mathcal{O}_K\subseteq A\subseteq \bigoplus_{n\ge 0}\frac{f_n}{n!}\cdot \mathcal{O}_K.
$$
Moreover, define
$$
m(\mathfrak{p},n):=\min_{\alpha\in\mathcal{O}_K}\operatorname{ord}_\mathfrak{p}(f_n(\alpha)).
$$
It is easy see that $I_n=\prod_{\mathfrak{p}}\mathfrak{p}^{m(\mathfrak{p},n)}$. let $f(\mathfrak{p})$ be the residue class degree and $e(\mathfrak{p})$ be the ramification index, then I believe that
$$
m(\mathfrak{p},n) = \begin{cases}
\operatorname{ord}_p(n!)\quad&\text{if $f(\mathfrak{p})=e(\mathfrak{p})=1$}\\
\left\lfloor\frac np\right\rfloor&\text{if $f(\mathfrak{p})=1$ and $e(\mathfrak{p})>1$}\\
0&\text{otherwise.}
\end{cases}
$$
Which makes the lower bound fairly concrete. The lower and upper bounds are equal only when $K=\mathbb{Q}$. In this case, we find that
$A = \bigoplus_{n\ge 0}{X\choose n}\cdot \mathbb{Z}$
Questions:

*

*Can you compute $A$ for a few number fields other than $\mathbb{Q}$? Is there an algorithm to do it in general?

*Is $A$ free as a $\mathcal{O}_K$-module?

*Can you compute a minimal generating set (so a basis if the answer to the previous question is affirmative) for $A$ for a few number fields other than $\mathbb{Q}$? Is there an algorithm to do it in general?

Proof of the upper bound
Define $\Delta:A\to A$ by $\Delta f:=f(X+1)-f(X)$. Note that all constant polynomials in $A$ lie in $\mathcal{O}_K$. Let $f\in A$ have degree $d$ and leading coefficient $a_d\in K$, then $\Delta^{(d)}f=d!a_d\in\mathcal{O}_K$, and $f-d!a_d\cdot \frac{f_d}{d!}=f-d!a_d{X\choose d}$ has degree strictly less than $f$. Induction on the $\deg(f)$ finishes the job.
 A: I decided to work out the details of reuns' comment, because I didn't understand it, and while it doesn't directly answer my question, it does shed some light on the structure of $A$.

Let $K$ be a number field, $\mathcal{O}:=\mathcal{O}_K$ its ring of integers and let $A$ be as in the question. For all $p\in\mathbb{Z}$ prime, write $\mathcal{O}_p:=\{1,p^{-1},p^{-2},\ldots\}\mathcal{O}$ and $\mathcal{O}_{(p)}:=\{a/b:a,b\in\mathcal{O}|b\mathcal{O}+p\mathcal{O}=\mathcal{O}\}$
Fix a prime $p\in \mathbb{Z}$. For all $f\in K[X]$ there exists a positive integer $k$ such that the coefficients of $p^kf\in \mathcal{O}_{(p)}[X]$. Now, there exists a $g\in\mathcal{O}[X]$ satisfying
$$p^kf\equiv g\pmod {p^{k}}.$$
Lemma 1 Let $\varphi_p:K[X]\to \mathcal{O}_p[X]/\mathcal{O}[X]$ be given by $f\mapsto (p^{-k}g\mod \mathcal{O}[X])$. Then $\varphi_p$ is a well-defined $\mathcal{O}$-linear map and $\ker \varphi_p=\mathcal{O}_{(p)}[X]$.
Proof: First we show $\varphi_p$ is well-defined. Fix $f\in K[X]$ and $k\ge 0$, and suppose we have $g,g'\in\mathcal{O}[X]$ satisfying
$$p^kf\equiv g\equiv g'\pmod {p^k},$$
then $g-g'\in \mathcal{O}[X]\cap p^k\mathcal{O}_{(p)}[X]=p^k\mathcal{O}[X]$, whence $p^{-k}g\equiv p^{-k}g'\pmod {\mathcal{O}[X]}$.
In general, suppose we have $k,\ell\ge 0$ and $g,h\in\mathcal{O}[X]$ satisfying
$$p^kf\equiv g\pmod {p^k}\quad\text{and}\quad p^{k+\ell}f\equiv h\pmod {p^{k+\ell}},$$
then $p^\ell g\equiv h\pmod {p^{k+\ell}}$, whence $p^{-\ell}h\in\mathcal{O}[X]$. Take $g'=p^{-\ell}h$ in the previous claim, then $p^{-k}g\equiv p^{-(k+\ell)}h\pmod {\mathcal{O}[X]}$. We conclude that $\varphi_p$ is well-defined.
It is now a trivial verification to show that $\varphi_p$ is $\mathcal{O}$-linear. Now, $f\in \ker\varphi_p$ if and only if, for a sufficiently large $k$, we can find a $g\in\mathcal{O}[X]$ such that $p^kf\equiv g\pmod {p^k}$ and $p^{-k}g\in\mathcal{O}[X]$. Equivalently, $p^k(f-p^{-k}g)\in p^k\mathcal{O}_{(p)}[X]$, or $f-p^{-k}g\in\mathcal{O}_{(p)}[X]$. This is equivalent to $f\in \mathcal{O}_{(p)}[X]$. $\square$
Corollary 2 We have a well-defined $\mathcal{O}$-linear map
$$\varphi:K[X]\to \bigoplus_{p\text{ prime}}\mathcal{O}_p[X]/\mathcal{O}[X],\quad f\mapsto (\varphi_p(f))_{p}$$
with kernel $\mathcal{O}[X]$.
Proof: Let $f\in K[X]$, then $f\in \mathcal{O}_{(p)}[X]$ for all but finitely many primes $p$. Hence, $\varphi$ is well-defined. $\mathcal{O}$-linearity is clear. Moreover, $\ker\varphi = \bigcap_{p}\mathcal{O}_{(p)}[X]=\mathcal{O}[X]$. $\square$
Lemma 3 $\varphi$ is surjective.
Proof: Let $p_1,\ldots,p_n$ be distinct primes and, for all $1\le i\le n$, let $f_i\in \mathcal{O}_{p_i}[X]$ be given. For all $1\le i\le n$, write
$$f_i = \sum_{j=0}^d\frac{a_{ij}}{p^k}X^j,$$
where neither $d$ nor $k$ depends on $i$ and $a_{ij}\in\mathcal{O}$. For all $0\le j\le d$, there exists an element $a_j\in\mathcal{O}$ which satisfies
$$
a_j\equiv a_{ij}\prod_{\ell\neq i}p_\ell^k\pmod {p_i^k}\quad\text{ for all $1\le i\le n$,}
$$
by the Chinese Remainder Theorem. Now let $f:= \left(\prod_{i=1}^np_i^k\right)^{-1}\sum_{j=0}^da_jX^j$. With Lemma $1$, we find that
$$\varphi_{p_i}(f)=\left(f_i\mod \mathcal{O}[X]\right)\quad\text{for all $1\le i\le n$},$$
as well as $\varphi_q(f)=0$ for all primes $q\not\in\{p_1,\ldots,p_n\}$. $\square$

Now we return to $A$, as defined in the question. For all $p\in \mathbb{Z}$, define
$A_p:=A\cap \mathcal{O}_p[X].$
Lemma 4 Let $f\in K[X]$, then $f\in A$ if and only if $\varphi_p(f)\in A
_p/\mathcal{O}[X]$ for all primes $p$.
Proof: Let $f\in A$. Let $p$ be prime, let $k$ be a positive integer and let $g\in \mathcal{O}[X]$ such that $p^kf\equiv g\pmod {p^k}$, then $0\equiv p^kf(a)\equiv g(a)\pmod {p^k}$ for all $a\in\mathcal{O}$, whence $p^{-k}g\in A_p$ and $\varphi_p(f)\in A_p/\mathcal{O}[X]$ for all primes $p$, as desired.
On the other hand, let $f\in K[X]$ and assume that $\varphi_p(f)\in A_p/\mathcal{O}[X]$ for all primes $p$. As before, consider the congruence $fp^kf\equiv g\pmod {p^k}$. Per our assumption, $g(\mathcal{O})\subseteq p^k\mathcal{O}$. Hence, $f(\mathcal{O})\subseteq \mathcal{O}_{(p)}$. Because this is true for all primes, it follows that
$$f(\mathcal{O})\subseteq \bigcap_{p\text{ prime}}\mathcal{O}_{(p)}=\mathcal{O}$$
and $f\in A$. $\square$
Theorem 5 The $\mathcal{O}$-linear map $\varphi$ introduced in corollary $2$ induces an isomorphism of $\mathcal{O}$-modules,
$$\widetilde{\varphi|_A}:A/\mathcal{O}[X]\stackrel{\sim}{\to}\bigoplus_{p\text{ prime}}A_p/\mathcal{O}[X].$$
Proof: This follows immediately from Corollary $2$, Lemma $3$ and Lemma $4$. $\square$
