Is Number Odd?


Results 1 to 30 of 30

Thread: Is Number Odd?

Threaded View

  1. #25
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Another recursive method. However this time it uses the unique feature of Variable Rollover. Also, if nothing is found at the end of checking all possible values for a WORD, the outcome must be Zero.

    Code:
    TestNumber as word
    TestVal as word
    
    For TestVal = 65534 to 2 step -2
    	If (TestNumber + TestVal)= 0 Then
    		LCDOUT "Even"
    		EndProgram
    	Else
    		If (TestNumber + TestVal) + 1 = 0 then
    			LCDOUT "Odd"
    			EndProgram
    		Else
    	Endif
    Next TestVal
    	LCDOUT "Zero"
    EndProgram:
    end
    EDIT: This may be premature, I think I left a hole at the value of "65535". Standby
    Last edited by SteveB; - 11th June 2008 at 17:26.

Similar Threads

  1. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  2. dec number to show on lcd (maths)
    By savnik in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2007, 19:18
  3. Working with the random number generator
    By kwelna in forum mel PIC BASIC
    Replies: 9
    Last Post: - 16th January 2007, 17:50
  4. Random number results
    By bartman in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th March 2005, 17:39
  5. more random number questions
    By bartman in forum mel PIC BASIC
    Replies: 1
    Last Post: - 14th November 2004, 17:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts