Skip to main content
5 of 9
Golfed the code a bit more.
Rodolfo Dias
  • 4k
  • 2
  • 14
  • 20

First try at code-golfing.

#Java - 151 128 77 62 bytes

void f(int n){int i=0;for(;++i<=n;System.out.print((char)i));}

Usage:

import java.util.Scanner;
class A {

    public static void main(String[] a) {
        int num = new Scanner(System.in).nextInt();
        f(num);
    }

    void f(int n) {
        int i = 0;
        for (; ++i <= n; System.out.print((char) i));
    }
}

Thanks to Shujal, flawr and Ingo Bürk for the serious byte reduction.

Rodolfo Dias
  • 4k
  • 2
  • 14
  • 20