title: How can I use the gmp package to utilise a loop for an extremely large number?
body: <p>I have developed a loop that calculates the largest prime factor of a given number.</p>
  <pre><code>for(i in (p-1):(1)){
  if ((p%%i)==0){
  p&lt;-append(p,i)
  }
  }
  
  n&lt;-c()
  for (i in p){
  if (sum(i/1:i==i%/%1:i)==2){
  n=c(n,i)
  }
  }
  
  max&lt;-max(n)
  </code></pre>
  <p>This works for the numbers that r can handle. However, when I try this for the large number 600851475143 I recieve the error:</p>
  <pre><code>long vectors not supported yet
  </code></pre>
  <p>I understand this is a problem with r not being able to handle large numbers. I have tried getting around this by using the gmp package:</p>
  <pre><code>install.packages(&quot;gmp&quot;)
  library(gmp)
  </code></pre>
  <p>And using as.bigz with my number:</p>
  <pre><code> p&lt;-as.bigz(600851475143)
  </code></pre>
  <p>But this returns the error:</p>
  <pre><code>Error in (p - 1):(1) : unimplemented type 'raw' in 'asReal'
  In addition: Warning message:
  In (p - 1):(1) : numerical expression has 20 elements: only the first used
  </code></pre>
  <p>How would I use the gmp package (or a similar package) to perform the loop I have made?</p>
  <p>Thanks.</p>