Skip to content

Instantly share code, notes, and snippets.

@sonerb
Created December 25, 2016 17:12
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 sonerb/b1cfecb0fb8e819afde9aeafc9e7c7a2 to your computer and use it in GitHub Desktop.
Save sonerb/b1cfecb0fb8e819afde9aeafc9e7c7a2 to your computer and use it in GitHub Desktop.
clear, clc;
is_while = 1;
while is_while
sonuc = 0;
a = input('Bir sayı giriniz : ', 's');
if strcmp(a, 'cikis')
break;
end
a = str2double(a);
a = floor(a);
if ~isnan(a)
if a == 0
sonuc = 1;
fprintf('\nSonuç : %d\n\n', sonuc);
continue;
elseif a < 0
fprintf('\nNegatif Bir Sayı Girdiniz.\n\n');
continue;
else
sonuc = 1;
for b=1:a
sonuc = sonuc * b;
end
fprintf('\nSonuç : %d\n\n', sonuc);
continue;
end
else
fprintf('Lütfen sayı giriniz');
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment