natural n,i,P,c,cn
Begining
read n;
cn=n;
i=0;
While (cn>0) execute
c=cn mod 10;
if (c=0) then
i=i+1;
if closed
cn=cn div 10;
while closed
cn = x;
While (cn>0) execute
c=cn mod 10;
if (c mod 2 <>0) then...
nuko algorithm 1
Re: nuko algorithm 1
Okay to do this your way:
( % = mod btw)
Product = 0;
LET CN = N;
WHILE (CN <> 0) DO
Digit = CN % 10;
IF (Digit % 2 <> 0) THEN
IF (Product==0) THEN Product = 1;
Product = Product * Digit;
END IF
CN = CN - Digit;
CN = CN / 10;
END WHILE
OUTPUT Product;
( % = mod btw)
Product = 0;
LET CN = N;
WHILE (CN <> 0) DO
Digit = CN % 10;
IF (Digit % 2 <> 0) THEN
IF (Product==0) THEN Product = 1;
Product = Product * Digit;
END IF
CN = CN - Digit;
CN = CN / 10;
END WHILE
OUTPUT Product;
Nuko - In the event of malfunction, please insert tea.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Re: nuko algorithm 1
Code: Select all
P= 0;
LET CN = N;
WHILE (CN <> 0) DO
C= CN % 10;
IF (C% 2 <> 0) THEN
IF (P==0) THEN P= 1;
P= P* C;
END IF
CN = CN - C;
CN = CN / 10;
END WHILE
OUTPUT P;
Nuko - In the event of malfunction, please insert tea.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Re: nuko algorithm 1
Ty very much guys it helped me a lot
Who is online
Users browsing this forum: No registered users and 6 guests