Skip to content

Instantly share code, notes, and snippets.

@unalfaruk
Created May 20, 2020 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unalfaruk/3226dfd2515bcd83acf5924935a24cb5 to your computer and use it in GitHub Desktop.
Save unalfaruk/3226dfd2515bcd83acf5924935a24cb5 to your computer and use it in GitHub Desktop.
function result = isFactorionNumber(number)
result=0;
numberArray = num2str(number);
sum=0;
for i=1:1:length(numberArray)
sum=sum+factorial(str2num(numberArray(i)));
end
if isequal(number,sum)
result=1;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment