We report a proof-of-principle demonstration of Shor's algorithm with photons generated by an on-demand semiconductor quantum dot single-photon source for the first time. A fully compiled version of Shor's algorithm for factoring 15 has been accomplished with a significantly reduced resource requirement that employs the four-photon cluster state. Genuine multiparticle entanglement properties are confirmed to reveal the quantum character of the algorithm and circuit. The implementation realizes the Shor's algorithm with deterministic photonic qubits, which opens new applications for cluster state beyond one-way quantum computing.