フィルターのクリア

can you help me turn this algorithm to matlab and plotting the number of earring

3 ビュー (過去 30 日間)
ime sem
ime sem 2013 年 11 月 9 日
コメント済み: ime sem 2013 年 11 月 9 日
fonction pgd n:entier; var i debut i=2 tantque i≤n/2 et (n mod i)#0 faire i=i+1 fintantque si (n mod i)=0 alors pgd=n div i sinon pgd=n finsi fin

採用された回答

Roger Stafford
Roger Stafford 2013 年 11 月 9 日
編集済み: Roger Stafford 2013 年 11 月 9 日
It looks as though you want to find the largest divisor of n less than n if n is not a prime number, and otherwise the prime number n itself. You could perhaps make your code more efficient if you replaced "i≤n/2" with "i<=sqrt(n)".
I am not sure about the name of your function. I don't understand that request about "plotting the number of earring".
function pgd = entier(n)
i = 2;
while in/2 & mod(n,i)~-0
i = i+1;
end
if mod(n,i)==0
pgd = n/i;
else
pgd = n;
end
end
  1 件のコメント
ime sem
ime sem 2013 年 11 月 9 日
plotting the number of actions for ex i=i+1 ( action) pgd=n/i ( action) pgd=n(action)

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

その他の回答 (0 件)

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by