nuko algorithm 1

Off-topic posts of interest to the World of Warcraft community.
Post Reply
User avatar
Drunky
Posts: 18
Joined: 13 Jan 2012 20:47

nuko algorithm 1

#1 » Post by Drunky » 07 Oct 2012 20:47

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...

User avatar
Nuko
Former Staff
Posts: 540
Joined: 27 Aug 2010 21:47
Location: United Kingdom

Re: nuko algorithm 1

#2 » Post by Nuko » 07 Oct 2012 20:52

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;
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."

User avatar
Nuko
Former Staff
Posts: 540
Joined: 27 Aug 2010 21:47
Location: United Kingdom

Re: nuko algorithm 1

#3 » Post by Nuko » 07 Oct 2012 20:59

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."

User avatar
Drunky
Posts: 18
Joined: 13 Jan 2012 20:47

Re: nuko algorithm 1

#4 » Post by Drunky » 07 Oct 2012 21:22

Ty very much guys it helped me a lot ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests