Powermod involving REALLY large integers
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-12-9
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numbers and Precision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!