11.10.2015 Views

Divisores

LfDvOp

LfDvOp

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

n=n+1 (se incrementa el número a probar)<br />

if a/n=int(a/n) then vale=false (Si es divisible paramos)<br />

wend<br />

if n=a then n=1 (Caso en el que a es primo)<br />

menordiv=n<br />

End function<br />

F UNCIÓN MDI<br />

Argumento: Un número entero positivo<br />

Valor: Devuelve el mayor divisor impar de dicho número.<br />

Código en Basic<br />

Public Function mdi(n) 'mayor divisor impar<br />

Dim s<br />

s = n<br />

While s/2=int(s/2): s = s / 2: Wend ‘va eliminando el factor 2 para que quede impar<br />

mdi = s<br />

End Function<br />

130

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

Saved successfully!

Ooh no, something went wrong!