Odd or Even numbers

Just starting out? Need help? Post your questions and find answers here.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

PeterGams wrote:The second row runs into 2 digits. And won't rotate back to start.
Any ideas ?

Code: Select all

num5 = 5 : num6 = 8            ; or whatever 
initialNum6 = num6 
initialNum5 = num5
Repeat 
  Debug Str(num6) + " - " + Str(num5); + Str(initialNum)  ; Or whatever is being done with it 
  num6 + 2 : num5 + 2
  If num6 > 9 :  num6 - 10 
    If num5 > 9 :  num5 - 10

    EndIf
  EndIf 
  
Until num6 = initialNum6 : Or num5 = initialnum5
Here are two bits of code for you.

Code: Select all

a.l = 5
For i.l = 1 To 5
   a = (a + 2) % 10
   Debug a
Next i
That one should be a fairly quick way of doing it.

Code: Select all

Dim b.l(2)
b(0) = 3
b(1) = 4
b(2) = 1
For i.l = 1 To 5
   ;
   b(0) = (b(0) + 2) % 10
   b(1) = (b(1) + 2) % 10 
   b(2) = (b(2) + 2) % 10
   ;
   Debug Str(b(0))+" "+Str(b(1))+" "+Str(b(2))
   ;
Next i
To get your three columns.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Please, watch the thread at the german forum. I postet my code there, too. My german mates have made some good improvements, you should have a look at their work!

[http://www.purebasic.fr/german/viewtopi ... ight=AND51]
PB 4.30

Code: Select all

onErrorGoto(?Fred)
PeterGams
User
User
Posts: 25
Joined: Sun Dec 03, 2006 4:19 am
Location: Australia

Post by PeterGams »

WOW !!
You blokes really rock..
Thanks heaps for your help...
Post Reply