Question:
To accept two numbers from the user and display Armstrong
numbers between these two numbers
Answer:
a = input(' Enter your 1st number: ');
b = input('\n Enter your 2st number: ');
for i = a:b
if isprime(i)
fprintf('%d, ', i)
end
end
fprintf('\n')
Output:
Enter your 1st number: 1
Enter your 2st
number: 100
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89, 97,
why did you use isprime here?
ReplyDelete