Jump to content

Math syntax I'm having trouble with...


Recommended Posts

I was a math major long ago, but I'm drawing a blank on this one. :) I suspect someone else can figure this out in less than a minute. I have a For/Next loop that goes from 1 to 500. I need to be able to tell which group x falls in (see graphic for the two groups). Here's what I want the code to say, but I don't know how to word the If x is in Group 1 Then and the ElseIf x is in Group 2. I realize I probably don't need the ElseIf, i.e., it could probably just be a plain Else.

For x = 1 to 500
    If x is in Group 1 Then
        do something here
    ElseIf x is in Group 2 Then
        do something here
    EndIf
Next

Here are the groups:

Posted Image

Thank you. :D

Link to comment
Share on other sites

  • Developers

Some logic to identify Group1 and Group2:

For $x = 1 to 500
    If ($x/16) - Int($x/16) = 0 Then
        $group = 2
    ElseIf ($x/16) - Int($x/16) < .51 Then
        $group = 1  
    Else
        $group = 2  
    EndIf
    MsgBox(262144,'Debug',"x=" & $x & "  $group=" & $group);### Debug MSGBOX
Next

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I was a math major long ago, but I'm drawing a blank on this one. :)  I suspect someone else can figure this out in less than a minute.  I have a For/Next loop that goes from 1 to 500.  I need to be able to tell which group x falls in (see graphic for the two groups).  Here's what I want the code to say, but I don't know how to word the If x is in Group 1 Then and the ElseIf x is in Group 2.  I realize I probably don't need the ElseIf, i.e., it could probably just be a plain Else.

For x = 1 to 500
    If x is in Group 1 Then
        do something here
    ElseIf x is in Group 2 Then
        do something here
    EndIf
Next

<{POST_SNAPBACK}>

The Mod function.

For $x = 0 To 33
   $iRem = Mod($x, 16)
   If $iRem > 0 And $iRem < 9 Then
      MsgBox(4096, "Group1", $X & " = Group1", 1)
   Else
      MsgBox(4096, "Group2", $X & " = Group2", 1)
   EndIf
Next

Phillip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...