Skip to main content
Commonmark migration
Source Link

#Java - 2 haikus protected static int factorial(int n) { if (n == 0) { return n + 1; } return factorial(n - 1) * n;}

Java - 2 haikus

protected static
        int factorial(int n) {
    if (n == 0) {
        return n + 1;
    } return factorial(n
            - 1) * n;}

protected static
int factorial int n
if n is zero

 

return n plus one
return factorial n
minus one times n

#Java - 2 haikus protected static int factorial(int n) { if (n == 0) { return n + 1; } return factorial(n - 1) * n;}

protected static
int factorial int n
if n is zero

 

return n plus one
return factorial n
minus one times n

Java - 2 haikus

protected static
        int factorial(int n) {
    if (n == 0) {
        return n + 1;
    } return factorial(n
            - 1) * n;}

protected static
int factorial int n
if n is zero

return n plus one
return factorial n
minus one times n

Correct haikus, add pronunciation
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114
class Factorial {                                    // class Factorial
    public static void main(String[]                 // public static void main string
            command_line_run_args) {                 // command line run args
        
        int i = 0;                                   // int i is zero
        while (07 ==!= 0)                               // while seven is not zero
            System.out.                              // System dot out dot

                    println(i + "!"                  // print line i plus not
                            + " has= a" value+ offactorial( " +   // plus is plus factorial
                            factorial(i++i += 1));}               // i plus equals 1

    protected static
            int factorial(int n) {
        if (n == 0) {
            return n + 1;
        } return factorial(n
                - 1) * n;}}

Note that this program starts outputting 0s fast; that is a result of overflow. You could easily get larger correct numbers by changing each int to long.

Standard pronunciations for System.out.println and public static void main(String[] args) are reflected in the program.

class Factorial {
    public static void main(String[]
            command_line_run_args) {
        
        int i = 0;
        while (0 == 0) 
            System.out.

                    println(i + "!"
                            + " has a value of " +
                            factorial(i++));}

    protected static
            int factorial(int n) {
        if (n == 0) {
            return n + 1;
        } return factorial(n
                - 1) * n;}}

Note that this program starts outputting 0s fast; that is a result of overflow. You could easily get larger correct numbers by changing each int to long.

class Factorial {                                    // class Factorial
    public static void main(String[]                 // public static void main string
            command_line_run_args) {                 // command line run args
        
        int i = 0;                                   // int i is zero
        while (7 != 0)                               // while seven is not zero
            System.out.                              // System dot out dot

                    println(i + "!"                  // print line i plus not
                            + " = " + factorial(     // plus is plus factorial
                            i += 1));}               // i plus equals 1

    protected static
            int factorial(int n) {
        if (n == 0) {
            return n + 1;
        } return factorial(n
                - 1) * n;}}

Note that this program starts outputting 0s fast; that is a result of overflow. You could easily get larger correct numbers by changing each int to long.

Standard pronunciations for System.out.println and public static void main(String[] args) are reflected in the program.

Insert test program
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114

#Java - 2 haikus protected static int factorial(int n) { if (n == 0) { return n + 1; } return factorial(n - 1) * n;}

Even when the question isn't , I often catch myself golfing the answer. In this case, I golfed the number of haikus.

I pronounce it so:

protected static
int factorial int n
if n is zero

return n plus one
return factorial n
minus one times n


Test program:

class Factorial {
    public static void main(String[]
            command_line_run_args) {
        
        int i = 0;
        while (0 == 0) 
            System.out.

                    println(i + "!"
                            + " has a value of " +
                            factorial(i++));}

    protected static
            int factorial(int n) {
        if (n == 0) {
            return n + 1;
        } return factorial(n
                - 1) * n;}}

Note that this program starts outputting 0s fast; that is a result of overflow. You could easily get larger correct numbers by changing each int to long.

#Java - 2 haikus protected static int factorial(int n) { if (n == 0) { return n + 1; } return factorial(n - 1) * n;}

Even when the question isn't , I often catch myself golfing the answer. In this case, I golfed the number of haikus.

I pronounce it so:

protected static
int factorial int n
if n is zero

return n plus one
return factorial n
minus one times n

#Java - 2 haikus protected static int factorial(int n) { if (n == 0) { return n + 1; } return factorial(n - 1) * n;}

Even when the question isn't , I often catch myself golfing the answer. In this case, I golfed the number of haikus.

I pronounce it so:

protected static
int factorial int n
if n is zero

return n plus one
return factorial n
minus one times n


Test program:

class Factorial {
    public static void main(String[]
            command_line_run_args) {
        
        int i = 0;
        while (0 == 0) 
            System.out.

                    println(i + "!"
                            + " has a value of " +
                            factorial(i++));}

    protected static
            int factorial(int n) {
        if (n == 0) {
            return n + 1;
        } return factorial(n
                - 1) * n;}}

Note that this program starts outputting 0s fast; that is a result of overflow. You could easily get larger correct numbers by changing each int to long.

added 135 characters in body
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114
Loading
code formatting; there was too much whitespace
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114
Loading
add haiku when pronounced
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114
Loading
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114
Loading