factorpairs

버전 1.0.0.0 (2.05 KB) 작성자: John D'Errico
Generate all pairs of factors N = p*q, p <= q, for positive integer N
다운로드 수: 770
업데이트 날짜: 2010/3/29

라이선스 보기

I needed a tool that would generate all simple pairs of factors of a positive integer N, where N could be rather large. I also needed this task to be accomplished efficiently. So while I liked the nfactork submission that Matt Fig has posted, I found it to have severe problems with memory for some numbers. Therefore I had to write my own tool for the task that handles the case where exactly two factors are generated.

factorpairs(72)
ans =
1 72
2 36
3 24
4 18
6 12
8 9

The factorpairs function is quite efficient for large N with many factors. It works for any value of N that does not exceed 2^32.

tic
F = factorpairs(factorial(12));
toc

Elapsed time is 0.003767 seconds.

There are 396 distinct pairs of factors generated here.

size(F)
ans =
396 2

인용 양식

John D'Errico (2024). factorpairs (https://www.mathworks.com/matlabcentral/fileexchange/27113-factorpairs), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2010a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0