How to get prime factorization with a factor base in wolfram alpha?

350 Views Asked by At

How can I get the prime factors of a (non-prime) number, with all the primes being less than a factor base B.

For example if B=8, then the primes used can only be in {2,3,5,7}. And given 48, it returns 2^4 * 3.

Anyone know how to do this in wolfram alpha?

Thanks

2

There are 2 best solutions below

2
On

You can't.

The prime factors of a number are a property of the number itself, not its representation in any particular base. As a simple example, there is no prime factor of 11 that is less than 8.

0
On

Sorry, don't know anything about mathematica but here is an algorithm that works:

Divide the starting value, B, by 2 and check the remainder.

If remainder is zero, 2 was a factor. If not, try other primes, [3, 5, 7, ...] up to half of the starting value.

Repeat the process by dividing the starting value by whatever factor you just found and starting again with that.

If you are working with very large numbers then be careful with the precision of the division.