How to synchronize The Loop with the max post per page?

You can retrieve the setting for posts per page set under Settings > Reading via get_option:

$posts_per_page = get_option( 'posts_per_page' );