The Midrash says that the Flood lasted forty days because the people transgressed the Torah which was given in forty days. The Midrash also says that Hashem waited another seven days before bringing the Flood.