MATLAB Answers

Powermod involving REALLY large integers

2 ビュー (過去 30 日間)
Yuechuan Chen
Yuechuan Chen 2019 年 12 月 9 日
Commented: Yuechuan Chen 2019 年 12 月 9 日
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 件のコメント

サインイン to comment.

採用された回答

Walter Roberson
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

  1 件のコメント

Yuechuan Chen
Yuechuan Chen 2019 年 12 月 9 日
Ohhh I see. Thank you so much!

サインイン to comment.

More Answers (0)

サインイン してこの質問に回答します。


Translated by