matlab求完全数?

2024-11-08 09:55:27
推荐回答(1个)
回答1:

clc
clear all
n = input('请输入n的值(100)');
m = input('请输入m的值(500)');
for s = n:m
y = 0;
for i = 1:(s - 1)
if mod(s,i) == 0
y = y + i;
end
end
if y == s
s
end
end