フィルターのクリア

my error in the write n!+1 = 0 mod n

1 回表示 (過去 30 日間)
Mohammed AL Rashedi
Mohammed AL Rashedi 2023 年 3 月 5 日
コメント済み: Dipankar 2024 年 6 月 11 日
n=1:500;
n_true = [];
for i=1:length(n)
x = 2:n(i);
nq=factorial(n(i)))+1;
x3 = mod(0,n(i));
if ~any(x3 == nq)
n_true(end+1) = n(i);
end
end
i want find all n values by n!+1 = 0 mod n
  3 件のコメント
Steven Lord
Steven Lord 2023 年 3 月 5 日
By the definition of the factorial function, factorial(n) is equivalent to 0 mod n as it is n*factorial(n-1). [The base case where n = 0 is handled by the convention, listed on the mod documentation page, that mod(x, 0) is x.] So you're looking for values of n for which 1 is also equivalent to 0 mod n. That would mean 1 is an integer multiple of n. For how many values of n is this true?
Dipankar
Dipankar 2024 年 6 月 11 日
it was tried to found out the solution of Brocards problem

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

回答 (1 件)

Jan
Jan 2023 年 3 月 5 日
編集済み: Jan 2023 年 3 月 5 日
nq=factorial(n(i)))+1;
% ^
Here are more closing then opening parentheses.
Whenever you mention an error in the forum, attach a copy of the complete message.
This is strange also:
x3 = mod(0,n(i))
This checks, if 0 is divisable by n(i). Even the equation n!+1 = 0 mod n looks confusing.
  4 件のコメント
the cyclist
the cyclist 2023 年 3 月 5 日
Of course. Now I feel dumb. Well, dumber than usual. :-)
Mohammed AL Rashedi
Mohammed AL Rashedi 2023 年 3 月 5 日
Dear the cyclist exactly, "I think he is trying to find n where" .Thank you Walter Roberson .
Thank you guys. I love you

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by