Asked by Mohsin Shah
on 20 May 2011

Howto find factors of 2^1024 and 2^2048 in Matlab??

Answer by Daniel Shub
on 20 May 2011

repmat(factor(2), 1, 1024)

Walter Roberson
on 20 May 2011

That calculation takes a non-trivial amount of time...

Sean de Wolski
on 20 May 2011

And with the world ending in just a few hours ;-)

Andrew Newell
on 20 May 2011

Oh, no! So little time left to answer questions!

Sign in to comment.

Answer by Walter Roberson
on 20 May 2011

Sign in to comment.

Answer by John D'Errico
on 20 May 2011

No problem. Just use a tool designed to solve the problem.

>> factor(vpi(2)^1024)

ans =

Columns 1 through 16

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 17 through 32

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 33 through 48

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

...

And so on for all 1024 factors of the number.

Sign in to comment.

Answer by Andy
on 20 May 2011

Walter Roberson
on 20 May 2011

Andy
on 20 May 2011

Sign in to comment.

Answer by Andrew Newell
on 20 May 2011

The Symbolic Toolbox has a really nice way of handling this:

two = sym(2);

factor(two^1024)

ans =

2^1024

Walter Roberson
on 20 May 2011

factor() for the symbolic toolbox does algebraic factoring and does not touch numbers.

I do not know at the moment how to produce factors in MuPad; in Maple it would be by using ifactor() or numtheory[divisors]() or one of the related numtheory package members.

Walter Roberson
on 21 May 2011

In Maple,

numtheory[divisors](2^512-5) %a smaller problem

yields an error,

Error, (in ifactor/QuadraticSieve) object too large

It thus seems unlikely that Maple would be able to factor 2^2048-5 using the built-in routines.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## John D'Errico (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/7893-factorization#comment_16749

Sign in to comment.