Stabilization of a System of Unstable Pendulums: Discrete and Continuous Case