Hi Kevin Wright,


Re:
> 
> I am very new to 'R' and am trying to write an R function which returns the
> prime factors of a given number(n)
> 
> Unfortunately, the function only works for very small numbers, if for
> example I pass 18 to the function
> a mysteriously long vector is returned. I have not been able to find where
> or why this is happening.
> I know I've done something wrong. I've tried using debugging statements.
> Sometimes the
> currentPrime variable seems to become some sort of array?!
> 
> 
> can you help?
> 
> 
> library(gmp)
> 


But why writing one? Such a function is already in gmp: factorize(n), and
it works with fairly large numbers:

>library(gmp)
>factorize(12345678987654321)
Big Integer ('bigz') object of length 13:
 [1] 2   2   2   2   5   7   11  73  101 109 109 137 167

Success,

Frank
------




Franklin Bretschneider
Dept of Biology
Utrecht University
brets...@xs4all.nl

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to