필터 지우기
필터 지우기

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일)
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