Prime Factor Algorithm with TDD