Alternating harmonic series

버전 1.0.1 (1.15 KB) 작성자: Hoi Sing Lau
Alternating harmonic series
다운로드 수: 0
업데이트 날짜: 2025/8/30

라이선스 보기

1 - 1/2 + 1/3 - 1/4 + ...,
n = 2;
p = 6*n+1;
t = 1:1:4*n;
s = isprime(p);
f = fractional(n);
plot(t,f,'--');
title("Alternating harmonic series");
legend("H(n)");
f = sum(f);
format rational
[num, dem] = rat(f);
fprintf("The sum of the series: %d/%d \n",num,dem);
q = mod(num,p);
if((q==0)&&(s==1))
fprintf("The fraction is a multiple of the prime number %d.",p);
end
function [S] = fractional(n)
S = [];
for i = 1:4*n
S(end+1) = ((-1).^(i+1))./i;
end
end

인용 양식

Hoi Sing Lau (2025). Alternating harmonic series (https://kr.mathworks.com/matlabcentral/fileexchange/181916-alternating-harmonic-series), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2024b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
태그 태그 추가
도움

도움 받은 파일: Sum of Harmonic Series of natural numbers

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.1

curve smoothing on the image

1.0.0