Powermod involving REALLY large integers
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yuechuan Chen
el 9 de Dic. de 2019
Comentada: Yuechuan Chen
el 9 de Dic. de 2019
So basically I'm trying to use powermod with very big numbers. I have s=1473687476915250164368566014542081756221043781677543142805. when I do powermd(7,s,n) it comes with with an error message:'must be a nonnegative integer.'(see image attached)
I don't see any mistakes in my script, could someone explain to me why this is occuring pls
THANK YOU!
digits 100
n=sym('94315998522576010519588224930693232398146802027362761139521');
a=7;
i=1;
while mod(n-1,2^i)==0
i=i+1;
end
i
r=i-1
s=vpa((n-1)/2^r)
powermod(7,s,n)
0 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Dic. de 2019
Even though you have set digits large enough, s=vpa((n-1)/2^r) always produces a symbolic floating point number because that is what vpa() is defined to do. powermod() cannot work with symbolic floating point numbers.
There are advanced techniques that could force the symbolic engine to convert s from symbolic floating point to symbolic integer, but they are obscure... and they are unnecessary. Just leave out the vpa() part in defining s, just s = (n-1)/2^r
Más respuestas (0)
Ver también
Categorías
Más información sobre Numbers and Precision en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!