hit upon

中高级 (B2) formal

To suddenly think of or find a good idea, sometimes by accident.

"Newton is said to have hit upon his theory of gravity after observing a falling apple."