يمكنك إستخدام الكود أدناه
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear,clc
n = input(
'input number of the counting loops ')
% number(i) is the i-th digit of the input number (should be 0 or 1)
number(1) = input(
'input the first digit of your number ');
number(2) = input(
'input the second digit of your number ');
number(3) = input(
'input the third digit of your number ');
number(4) = input(
'input the fourth digit of your number ');
for i=1:n
shift = XOR( number(3),number(4) );
% aux is auxiliary vector to save the digits
aux(1) = number(1);
aux(2) = number(2);
aux(3) = number(3);
% replacing the old digits with the new ones
number(1) = shift;
number(2) = aux(1);
number(3) = aux(2);
number(4) = aux(3);
end
'our final number is'
number
لقد جربت البرنامج وهو يعمل
تحياتي