Determine smallest single-digit factor : for « Language Basics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Language Basics » forScreenshots 
Determine smallest single-digit factor
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
1.Simplest forSimplest for
2.For loop for array
3.The finished C# statement Help system that processes multiple requestsThe finished C# statement Help system   
   that processes multiple requests
4.A negatively running for loopA negatively running for loop
5.Determine if a number is prime. If it is not, then display its largest factorDetermine if a number is prime.  If it is not, 
   then display its largest factor
6.loop with letter char as the control variable
7.Use commas in a for statememtUse commas in a for statememt
8.Use commas in a for statememt to find the largest and smallest factor of a numberUse commas in a for statememt to find 
   the largest and smallest factor of a number
9.Loop condition can be any bool expressionLoop condition can be any bool expression
10.Parts of the for can be emptyParts of the for can be empty
11.Move more out of the for loopMove more out of the for loop
12.The body of a loop can be emptyThe body of a loop can be empty
13.Declare loop control variable inside the forDeclare loop control variable inside the for
14.Using break to exit a loopUsing break to exit a loop
15.Use continueUse continue
16.Demonstrate the for loopDemonstrate the for loop
17.Compute the sum and product of the numbers from 1 to 10. Compute the sum and product of the numbers from 1 to 10.
18.For Loop TesterFor Loop Tester
19.If inside a forIf inside a for
20.For without init valueFor without init value
21.For without increaseFor without increase
22.For with empty conditionFor with empty condition
23.a for loop to display 1 to 5a for loop to display 1 to 5
24.Update two parameters in for loop
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.