11.10.2015 Views

Divisores

LfDvOp

LfDvOp

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

x1 = x1 / m ‘no hay que usar un IF porque es divisible con seguridad<br />

Wend<br />

smar2 = n<br />

End Function<br />

Con esta nueva implementación podemos calcular S(x) para valores<br />

mayores. Lo hemos intentado para comprobar que S(200001)=409 y se<br />

ha conseguido de forma prácticamente instantánea. Coincide con el<br />

resultado obtenido con PARI.<br />

El problema está en que necesitas la función MCD. Aquí tienes una:<br />

Public Function mcd(a1, b1)<br />

Dim a, b, r<br />

'Halla el MCD de a1 y b1<br />

r = 1<br />

a = a1<br />

b = b1<br />

If b = 0 Then b = 1<br />

If a = 0 Then a = 1<br />

While r 0<br />

r = a - b * Int(a / b)<br />

If r 0 Then a = b: b = r<br />

Wend<br />

mcd = b<br />

End Function<br />

Puedes estudiar esta versión muy sintética en PARI:<br />

a(n)={local(m=1,x=n);while(x>1,m++;x=x/gcd(x,m));m}<br />

72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!