Determine smallest single-digit factor
/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Determine smallest single-digit factor.
using System;
public class Ladder {
public static void Main() {
int num;
for(num = 2; num < 12; num++) {
if((num % 2) == 0)
Console.WriteLine("Smallest factor of " + num + " is 2.");
else if((num % 3) == 0)
Console.WriteLine("Smallest factor of " + num + " is 3.");
else if((num % 5) == 0)
Console.WriteLine("Smallest factor of " + num + " is 5.");
else if((num % 7) == 0)
Console.WriteLine("Smallest factor of " + num + " is 7.");
else
Console.WriteLine(num + " is not divisible by 2, 3, 5, or 7.");
}
}
}
Related examples in the same category