Ad
Code
Diff
  • f=lambda n: 91 if n <= 100 else n - 10
    • f=lambda n:max(n-10,91)
    • f=lambda n: 91 if n <= 100 else n - 10
Algorithms
Logic
Algebra
Mathematics
Code
Diff
  • int foo(int n){
          if (n < 0) {
            return 0;
          }
          
          int count_3 = n / 3;
          int count_7 = n / 7;
          int count_21 = n / 21;
        
          return
            count_3 *(3 + n - n % 3) /2 +
            count_7 *(7 + n- n % 7) / 2 -
            count_21 *(21 + n - n % 21) /2;
    }
    • int foo(int n){
    • int sum=0;
    • for (int i =1; i <= n; i++)
    • {
    • if (i % 3 == 0 || i % 7 == 0)
    • {
    • sum+=i;
    • }
    • }
    • if (n==1){
    • return 1;
    • }else
    • return sum;
    • if (n < 0) {
    • return 0;
    • }
    • int count_3 = n / 3;
    • int count_7 = n / 7;
    • int count_21 = n / 21;
    • return
    • count_3 *(3 + n - n % 3) /2 +
    • count_7 *(7 + n- n % 7) / 2 -
    • count_21 *(21 + n - n % 21) /2;
    • }