フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Write a function called prime_pairs that returns the smallest prime number p smaller than 100,000 such that (p + n) is also prime, where n is a scalar integer and is the sole input argument to the function. If no such number exists, then the function

1 回表示 (過去 30 日間)
krushnasamy subramaniyan
krushnasamy subramaniyan 2015 年 6 月 15 日
閉鎖済み: Walter Roberson 2015 年 6 月 15 日
function pr=prime(n)
np=1;c=0;
pr=zeros(1,n);
while np<=n
if isprime(np)
c=c+1;
pr(c)=np;
end
np=np+1;
end
pr=pr(1:c);

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by