Visiting the iniquity of the fathers upon the sons unto the third generation, and so forth (Exodus 20:5). Is this when they are not broken in sequence, or when they are broken in sequence? How so? A wicked man son of a wicked man. Rabbi Natan says: One who cuts off, son of one who cuts off. When Moses heard this thing, Moses made haste and bowed his head toward the earth and worshiped (Exodus 34:8). He said: Heaven forbid that there be in Israel a wicked man son of a wicked man. Or, just as the measure of punishment extends to four generations, so does the measure of goodness? Scripture teaches, to thousands (Exodus 20:6). If to thousands, I might hear the smallest meaning of thousands, namely two. Scripture teaches, to a thousand generations (Deuteronomy 7:9), generations upon generations, beyond searching out and beyond number.
The Iniquity of Fathers and a Thousand Generations of Mercy
Yalkut Shimoni on Torah 292:1
פּוֹקֵד עֲוֹן אָבוֹת עַל בָּנִים עַל שִׁלֵּשִׁים וְגוֹ', בִּזְמַן שֶׁהֵן אֵינָן מְסֹרָגִין, אוֹ בִּזְמַן שֶׁהֵן מְסֹרָגִין, הָא כֵּיצַד, רָשָׁע בֶּן רָשָׁע, רַבִּי נָתָן אוֹמֵר קוֹצֵץ בֶּן קוֹצֵץ, כֵּיוָן שֶׁשָּׁמַע מֹשֶׁה אֶת הַדָּבָר הַזֶּה (שמות לד, ח) "וַיְּמַהֵר מֹשֶׁה וַיִּקֹּד אָרְצָה וַיִּשְׁתָּחוּ". אָמַר חַס וְשָׁלוֹם אֵין בְּיִשְׂרָאֵל רָשָׁע בֶּן רָשָׁע. אוֹ כְּשֵׁם שֶׁמִּדַּת פֻּרְעָנוּת לְאַרְבַּע דּוֹרוֹת כָּךְ מִדַּת הַטּוֹבָה, תַּלְמוּד לוֹמַר לַאֲלָפִים. אִי לַאֲלָפִים שׁוֹמֵעַ אֲנִי מִעוּט אֲלָפִים שְׁנַיִם תַּלְמוּד לוֹמַר (דברים ז, ט) "לְאֶלֶף דּוֹר", דוֹרֵי דּוֹרִים לְאֵין חֵקֶר וְאֵין מִסְפָּר.