package com.github.jinsen47;

/**
 * Created by Jinsen on 16/5/3.
 */
public class SumWithoutOperator {
    public static int sum(int n) {
        int ret = 0;
        boolean ans = n == 0 || (ret = sum(n - 1)) > 0;
        return n + ret;
    }


    public static void main(String[] args) {
        System.out.println(sum(10));
    }
}

@@ -59,16 +59,94 @@
 16/5/3.%0A
+ *%0A * %E6%B1%821+2+3+...+n%EF%BC%8C%E8%A6%81%E6%B1%82%E4%B8%8D%E8%83%BD%E4%BD%BF%E7%94%A8%E4%B9%98%E9%99%A4%E6%B3%95%E3%80%81for%E3%80%81while%E3%80%81if%E3%80%81else%E3%80%81switch%E3%80%81case%E7%AD%89%E5%85%B3%E9%94%AE%E5%AD%97%E5%8F%8A%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5%EF%BC%88A?B:C%EF%BC%89%E3%80%82%0A
  */%0Apubl

Add comment