View Single Post
Old 15-08-2009, 13:01   #42
Jon T
cf.mega poster
 
Join Date: Jun 2003
Location: Mansfield, Notts
Age: 45
Services: Virgin Media Telephone and 100Mb broadband, Sky Q
Posts: 1,994
Jon T has reached the bronze age
Jon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze ageJon T has reached the bronze age
Re: Programming Challenges?

Quick and dirty 3 and 5 divisibility test in vbscript

Spoiler: 
Code:
Option Explicit

Dim intCount,intDividedBy3,intDividedBy5,strDecPoint

    For intCount=1 To 100
    intDividedBy3=intCount/3
    intDividedBy5=intCount/5
    strDecPoint="."

        If InStr(intDividedBy3,strDecPoint)=0 And InStr(intDividedBy5,strDecPoint)=0 Then 
            WScript.Echo  intCount & " is divisible by 3 and 5" 
                ElseIf InStr(intDividedBy3,strDecPoint)=0 Then WScript.Echo  intCount & " is divisible by 3"
                    ElseIf InStr(intDividedBy5,strDecPoint)=0 Then WScript.Echo  IntCount & " is divisible by 5" 
                        End If

    Next 
    
    Set intCount=Nothing
    Set intDividedBy3=Nothing
    Set intDividedBy5=Nothing
    Set strDecPoint=Nothing
    
WScript.Quit
Jon T is offline   Reply With Quote