Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

can you help me to turn this algorithm to matlab and plotting

조회 수: 1 (최근 30일)
ime sem
ime sem 2013년 11월 7일
마감: MATLAB Answer Bot 2021년 8월 20일
algorithm pgdA
n:entier
i:entier
tantque n mod i #0 faire i=i-1fintantque
pgdA=i
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 11월 7일
This appears to be exactly the same as the question that was previously Closed for you.
Walter Roberson
Walter Roberson 2013년 11월 7일
Google translate hints this would be:
algorithm PGDA
n: integer
i: integer
WHILE n mod i != 0 do i = i-1 END WHILE
PGDA = i

답변 (1개)

Walter Roberson
Walter Roberson 2013년 11월 7일
If the algorithm is intended to find the largest integer "i" such that "i" is a factor of n, then
function i = pdga(n)
factors = factor(n);
if length(factors) == 1
i = 1;
else
i = prod(factors(2:end));
end
end
However, your tags suggest that you might be trying to generate code for an FPGA. If so then your algorithm would need to be different, especially considering that FPGA often do not support division. In such a case it would probably be useful to have an upper bound on "n" ahead of time.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by