The Machine gave Carter's number to Finch when HR found out that Carter was looking into Beecher's murder.
Ernest Thornhill is the CEO of a data company, and he mysteriously hired all of his employees online. Reese and Finch went to see his company, and they learned that the people working there type data from dot matrix printouts into another computer, almost pointlessly. Finch traced Thornhill's last known location, and finds one of his algorithms within the coordinates. Reese and Finch came to realize that Thornhill was the Machine, and a self-defense mechanism against the virus that Decima had Kara Stanton upload.