Powermod involving REALLY large integers

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

採用された回答

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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by