LEGO Engineering

| | | | | | | |
How can a program be written to tell the difference between even and odd numbers?


22nd of April, 2010

(0 )

It would be possible to have the RCX or NXT count up to the number with a container, toggling between even and odd, but that wouldn't be as rapid a solution for very large values to test.

This part of the program tests whether or not the value in the red container is even or odd.  The yellow container is zero for even and one for odd.

even_vs_odd_pic_1.jpg


Here is that same piece of code in a program:

even_vs_odd_pic_2.jpg





AG
ses

   :
   :
* :
* :
 


Home | About Us | Contact Us

© 2013 Center for Engineering Educational Outreach, Tufts University
© 2013 The LEGO Group. All rights reserved.