The Messenger of Allah ﷺ came to me in the morning while I was glorifying Allah. He then left to attend to a need and returned around midday. He asked, "Have you been sitting here all this time?"I replied, "Yes."He said, "Shall I teach you words that, if weighed against all the glorifications you have uttered, would equal them? Say, 'Glory be to Allah, as many times as the number of His creation' three times. 'Glory be to Allah, the weight of His Throne' three times. 'Glory be to Allah, to the extent of His pleasure' three times. 'Glory be to Allah, as much as the ink of His words' three times."
حدثنا روح حدثنا حجاج حدثنا شعبة عن محمد بن عبد الرحمن مولى آل طلحة قال سمعت كريبا مولى ابن عباس يحدث عن ابن عباس
أتى علي رسول الله ﷺ غدوة وأنا أسبح ثم انطلق لحاجة ثم رجع قريبا من نصف النهار فقال ما زلت قاعدة قلت نعم فقال ألا أعلمك كلمات لو عدلن بهن عدلتهن أو لو وزن بهن وزنتهن يعني بجميع ما سبحت سبحان الله عدد خلقه ثلاث مرات سبحان الله زنة عرشه ثلاث مرات سبحان الله رضا نفسه ثلاث مرات سبحان الله مداد كلماته ثلاث مرات
Its isnad is sahih. Bukhari related it in Adab al-Mufrad, page 220, number 647, Nasai in 3/77, number 1352, in the chapter on forgetfulness (Sahw), Ibn Majah in 2/1251, number 3808, in the chapter on manners (Adab), and Ibn Khuzayma in 1/370, number 753.