import java.util.*;
import java.io.*;


/**
 * A miscellaneous collection of methods involving loops.
 */
public class LoopsConditionals {
  
  /** 
   * Ask the user for a number and print the positive
   * divisors of that number.
   */
  public static void printDivisors() throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int i = Integer.parseInt(br.readLine());
    for (int divisor=1; divisor <= i; divisor++){
      if (i%(divisor) ==0){
        System.out.println(divisor);
      }
    }
  }
  
  /**
   * Return the number of spaces in s.
   * @param s the String in which to look for spaces.
   * @return the number of spaces in s.
   */
  public static int countSpaces(String s) {
    int numSpaces=0;
    for (int i=0; i < s.length(); i++){
      if (s.charAt(i) == ' '){
        numSpaces++;
      }
    }
    return numSpaces;
  }
  
  
  /**
   * Use a StringTokenizer to print every other 
   * word in the String s.
   **/
  public static void everyOtherWord(String s) {
    StringTokenizer st = new StringTokenizer(s);
    boolean alternate = true;
    while (st.hasMoreTokens()) {
      if (alternate) {
        // print the word then change the flag so the next word is not printed.
        System.out.println(st.nextToken());
        alternate = false;
      } else {
        // go to the next word but don't print it then change the flag so the next
        // word is printed.
        st.nextToken();
        alternate = true;
      }
    }    
  }


}

