jweinst1
11/9/2015 - 6:53 AM

java function the operates in logarithmic time.

java function the operates in logarithmic time.

import java.util.Scanner;
/*Logarithmic time function that continously reduces
one side of a string*/

class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    System.out.println("Enter a phrase!");
    String f = reader.nextLine();
    while (f.length() > 1) {
        System.out.println(f);
        f = f.substring(0, f.length()/2);
    }
  }
}