View Single Post
Old 17-08-2009, 13:34   #69
LemonyBrainAid
Inactive
 
Join Date: Jul 2004
Location: 127.0.0.1
Services: 50MB Virgin w/ TiVo 1TB
Posts: 1,255
LemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze array
LemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze array
Re: Programming Challenges?

C#:

Spoiler: 
Code:
for (var i = 1; i < 100; i++)
{
    if (i % 3 && i % 5 == 0)
        Console.WriteLine(i + " is a multiple of both 3 and 5");
    if (i % 3 == 0)
        Console.WriteLine(i + " is a multiple of 3");
    if (i % 5 == 0)
        Console.WriteLine(i + " is a multiple of 5");
}


VB.NET:
Spoiler: 
Code:
Dim i As Integer

For i = 1 To 100
    If i Mod 3 AndAlso i Mod 5 = 0 Then
        Console.WriteLine(i + " is a multiple of both 3 and 5")
    End If
    If i Mod 3 = 0 Then
        Console.WriteLine(i + " is a multiple of both 3")
    End If
    If i Mod 5 = 0 Then
        Console.WriteLine(i + " is a multiple of both 3")
    End If
Next i


PHP:
Spoiler: 

PHP Code:
<?php
for ($i=1$i<100$i++)
  {
    if (
$i == 0)
    {
        if (
$i == 0)
        {
            echo(
$i." is a multiple of both 3 and 5<br />");
        }
        else
        {
            echo(
$i." is a multiple of 3<br />");
        }
    }
    if (
$i == 0)
    {
        if (
$i == 0)
        {
        echo(
$i." is a multiple of both 3 and 5<br />");
        }
        else
        {
        echo(
$i." is a multiple of 5<br />");
        }
    }
  }
?>

BASIC: (Not actually 100% this works, hah!)
Spoiler: 
Code:
10 FOR I$ = 1 TO 100
20 IF I$ % 3 AND I$ % 5 = 0 THEN GOTO 60
30 IF I$ % 3 = 0 THEN GOTO 70
40 IF I$ % 5 = 0 THEN GOTO 80
50 NEXT I$
60 PRINT I$ "is a multiple of both 3 and 5"
70 PRINT I$ "is a multiple of 3"
80 PRINT I$ "is a multiple of 5"
90 END
LemonyBrainAid is offline   Reply With Quote