Fuzzy Operators

S n = 1 + 2 3 × 4 ÷ 5 + 6 7 × 8 ÷ 9 + 10 n S_n = 1 + 2 - 3 \times 4\div 5 + 6 - 7 \times 8 \div 9 +10- \cdots n

Consider the above sum where the first n n positive integers are listed in ascending order, and the mathematical operations ( + , , × , ÷ ) (+,-,\times,\div) are repeated in that order.

Find the value of S 31417 S_{31417} . Give your answer to 3 decimal places.

Details and Assumptions :

  • BODMAS ( Order of Operations ) is obeyed.

  • A couple of explicit examples: S 4 = 1 + 2 3 × 4 = ( 1 + 2 ) ( 3 × 4 ) = 3 12 = 9 S 5 = 1 + 2 3 × 4 ÷ 5 = ( 1 + 2 ) ( 3 × 4 ÷ 5 ) = 3 12 ÷ 5 = 0.6. \begin{aligned} S_4 &= 1 + 2 - 3\times4 = (1+2) - (3\times4) = 3 - 12=-9 \\ S_5 &= 1+2-3\times4\div5 = (1+2) - (3\times4\div5) = 3 - 12\div5 = 0.6. \end{aligned}


The answer is -3.598164.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Guilherme Piaia
Dec 5, 2015

S 1 = 2 3 × 4 ÷ 5 + 6 7 × 8 ÷ 9 + . . . S - 1=2-3\times 4\div 5\ + 6-7\times 8\div 9+ ...

S 1 = n ( n + 1 ) × ( n + 2 ) n + 3 + . . . = n ( n + 2 n + 3 ) + . . . = 2 n + 3 . . . 2 N + 4 S - 1 = n - \frac{(n+1)\times(n+2)}{n+3} + ... = n - (n + \frac{2}{n+3})+... = - \frac{2}{n+3} - ... - \frac{2}{N+4}

n = N + 1 n= N+1

n = { 2 , 6 , 10 , . . . , N + 1 } n =\left\{ 2, 6, 10, ...,N+1 \right\}

S = 1 2 × ( 1 n + 3 + . . . + 1 N + 4 S = 1 - 2\times (\frac{1}{n+3} + ... +\frac{1}{N+4} ) = 1 2 × n = 1 N + 1 4 1 4 n + 1 1 - 2 \times \sum_{n=1}^\frac{N+1}{4} \frac{1}{4n+1}

MATLAB scripts

1
2
3
4
5
6
7
N = 31417;
sum = 1;

for n= 2:4:N+1
    sum = sum - 2/(n+3);
end
sum

1
2
3
4
5
6
7
N = 31417;
sum = 1;

for n = 1:(N+1)/4
    sum = sum - 2/(4.*n +1);
end
sum

The mathematics simplification is outstanding, I was asking if there are some math hacks for this prob!

Muhammad Arifur Rahman - 5 years, 6 months ago
Lu Chee Ket
Dec 4, 2015

With Excel of cells:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
1, 1, =B1
=4*(ROW()-2)+2, =A2-(A2+1)*(A2+2)/(A2+3), =C1+B2
...

for

1 1 1   1
2 2 -0.4    0.6
3 6 -0.222222222    0.377777778
4 10    -0.153846154    0.223931624
...
7853 31406  -6.3676E-05     -3.598036301
7854 31410  -6.36679E-05    -3.598099969
7855 31414  -6.36598E-05    -3.598163629

We can check sum of terms with step accumulations to agree each other.

-3.59816362860588 is the numerical value obtained.

Answer: 3.598 \boxed{-3.598}

There are thousands of Codes to solve this.

You can identify the Reappeared Sequence of the operators. s = 1 + ( 2 3 4 / 5 ) + ( 6 7 8 / 9 ) + ( 10 11 12 / 13 ) s=1+(2-3*4/5)+(6-7*8/9)+(10-11*12/13)

Now, get ready for the Loop. As you see, that "1" is kept out of the braces, you have to set the initial value of Sum, s=1; .

Then you take the 4 variables - a,b,c,d. You see, always, b = a + 1 b=a+1 c = b + 1 c=b+1 d = c + 1 d=c+1

And it occurs again and again. In the 1st loop, a=2 . You can declare it inside the for loop. To get the numbers of the 2nd loop, a+=4 . Because then you get a = 6 a=6 in the 2nd, and a = 10 a=10 in the 3rd loop and blah blah blah!

So, the for loop is for(a=2; ; a+=4) . Look carefully, we didn't specified the condition for the loop, because using the break; statement, we can do that job.

Then, inside the loop, first produce the other numbers, b , c , d b,c,d .

Now comes the most important. If a = n a=n , s + = a ; s+=a; then Break the loop.

But if b = n b=n , then s + = a b ; s+=a-b; , and Break ! Similar for c = n c=n and d = n d=n . Notice their statements in the program below.

If nothing of them isn't equals to n n , that means that they haven't reached the value of n n yet, which will happen from the beginning. For that, the statement is, s+=a-((b*c)/d); . Remember no Break this time, as it needs to continue until any of the variables reach the n n .

So, that's it. Here's the code after all this detailed explanation...

Compile, run it, Enter n=31417 and get the answer!

Any queries, comment box is open for you of course.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<conio.h>
#include<math.h>
int main()
{
    double a, b, c, d, s, n;
    printf("What's the n: ");
    scanf("%lf", &n);

    s = 1;
    for (a = 2;; a += 4)
    {
        b = a + 1;
        c = b + 1;
        d = c + 1;
        if (a == n)
        {
            s += a;
            break;
        }
        else if (b == n)
        {
            s += (a - b);
            break;
        }
        else if (c == n)
        {
            s += a - (b * c);
            break;
        }
        else if (d == n)
        {
            s += a - ((b * c) / d);
            break;
        }
        else

        {
            s += a - (b * c / d);
        }

    }
    printf("The Summation,s= %lf", s);
    printf("\n");


    return 0;
}

Alternatively, you can use recursive functions which shortens the code a lot. There's a nice recurrence relation for S n S_n which is,

S n = { n ( n 1 ) ( 1 ) + S n 2 n 0 ( m o d 4 ) ( ( n 1 ) ÷ n ) ( n 2 ) ( 1 ) + S n 3 n 1 ( m o d 4 ) n + S n 1 n 2 ( m o d 4 ) n ( 1 ) + S n 1 n 3 ( m o d 4 ) ; S 1 = 1 S_n=\begin{cases}\begin{aligned}n*(n-1)*(-1)+S_{n-2}&&\forall~n\equiv 0\pmod 4\\ ((n-1)\div n)\ast (n-2)*(-1)+S_{n-3}&&\forall~n\equiv 1\pmod 4\\ n+S_{n-1}&&\forall~n\equiv 2\pmod 4\\ n\ast (-1)+S_{n-1}&&\forall~n\equiv 3\pmod 4\end{aligned}\end{cases}\quad ;\quad S_1=1

This allows us to implement a recursive function for computing S n S_n very easily. Here 's the C++ implementation of the above recurrence relation to compute S n S_n .

Prasun Biswas - 5 years, 6 months ago

Log in to reply

Can you post a new solution with this logic? That really simplifies the Code.

Muhammad Arifur Rahman - 5 years, 6 months ago
Masbahul Islam
Dec 20, 2015

p=31417

x=2

y=3

s1=0.00

s2=0.00

while x<=p:

s1=s1+x

x=x+4.00

while y<=p:

if y+2<=p:

    s2=0.00+s2+y*(y+1)/(y+2.00)


elif p-y==1:

    s2=0.00+s2+y*(y+1)

elif p-y==0:

     s2=0.00+s2+y


y=y+4.00

print s1+1-s2

With which programming language you wrote the Code? Or its a Pseudocode ?

Muhammad Arifur Rahman - 5 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...