Lee said that he wrote the programme, Sudoku solver, in C++ several years ago, and shared the source code, the exe file, and a sample printout, Xinhua news agency reported.
He said the programme was pretty basic and explained how it worked in a DOS window.
Lee also left a question to be answered asking people to tell him if any bugs were found in the programme.
Recommended: Singapore firm Launches Mobile App for Halal Foodies
More than 5,000 people have shared the prime minister's post which gained 18,300 likes. Lots of netizens wrote down their comments to express their admiration as they did not know that Lee enjoyed coding.