2
$\begingroup$

How can I ask mathematica to sieve with only primes with three-digit less than a given number. Thank you for instance I want to find the prime factor of 1337. Thank you

$\endgroup$

3 Answers 3

4
$\begingroup$

1337 has four digits. You ask for primes with 3 digits less than that.

Select[Range[10^(Floor[Log10[1337]]-3),10^(Floor[Log10[1337]]-2)],PrimeQ]

gives you

{2,3,5,7}

which are the primes with 4-3==1 digit.

Select[{2,3,5,7},Mod[1337,#]==0&]

will use only those primes and sieve to find which of those are factors of 1337 giving you

{7}
$\endgroup$
3
$\begingroup$

Does the following answer your question?

factor = FactorInteger[1337]

{{7, 1}, {191, 1}}

Times @@ (#[[1]]^#[[2]] & /@ factor)

1337

$\endgroup$
1
$\begingroup$

You can try using NextPrime: NextPrime[1337, -1]

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.