It was 1647 not 1847 and by Fermat himself.
This was not the last theorem that Fermat wrote. Rather, it was the last one to be proven/disproven.
Fermat's Last Theorem is the popular science book by Simon Singh
1637
He didn't write it. What he did was to write in the margin of a book that he had a proof but there was not enough space to write it there.
Sir Andrew Wiles