Fixpoint Zsum_digit f k :=
  match k with
  | O => Z0
  | S k => (Zsum_digit f k + f (Z_of_nat k) * Zpower beta (Z_of_nat k))%Z
  end.

Theorem Zsum_digit_digit : forall n k, Zsum_digit (Zdigit n) k = Z.rem n (Zpower beta (Z_of_nat k)).