How quickly can you do this?

Let a a be the number of tuples ( a 1 , a 2 , a 3 , ) (a_1,a_2,a_3,\ldots) that satisfy the equation given below : i = 1 i a i = 45 \sum_{i=1}^{\infty} ia_{i}=45

Let b b be the number of tuples ( b 1 , b 2 , b 3 , ) (b_1,b_2,b_3,\ldots) that satisfy the inequality given below : i = 1 ( i + 1 ) b i 45 \sum_{i=1}^{\infty} (i+1)b_{i}\leq 45

Enter your answer by concatenating a a and b b . For example, if a = 23 a=23 and b = 65 b=65 , then enter 2365 2365 as your answer.


Details and Assumptions

  • a i 0 i Z + a_{i}\geq 0\ \forall\ i\in \Bbb Z^{+}
  • b i 0 i Z + b_{i}\geq 0\ \forall\ i\in \Bbb Z^{+}
  • Z + \Bbb Z^{+} denotes the set of all positive integers.
  • By title, I mean how quickly your program can do this.

Here are My CS Problems


The answer is 8913489134.

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.

2 solutions

Ronak Agarwal
Oct 25, 2015

Here's mine code in java

 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
class Maths_Calculator {


    public static void main(String[] args) {

    System.out.print(Partition(45,45)) ;
    }

public static int Partition(int i,int j){
int sum=0 ;
if(i<j)
    return Partition(i,i) ;
else
    if(j==0 || j==1)
      return 1 ;
    else
      {for(int k=1 ; k<j+1 ; k=k+1){
           sum=sum+Partition(i-k,k) ;

           }
      return sum ;      
      }

}

}

Pranjal Jain
Apr 7, 2015

Both of the given problems boils down to number of partitions of 45 45 .

For example,

  • Partitions of 1 are ( 1 ) (1)
  • Partitions of 2 are ( 1 + 1 ) , ( 2 ) (1+1),(2)
  • Partitions of 3 are ( 1 + 1 + 1 ) , ( 2 + 1 ) , ( 3 ) (1+1+1),(2+1),(3)

This can be easily done using Mathematica,

PartitionsP[45]

which gives output as 89134

Just concatenate it twice to get the answer 8913489134

Anyways, here's python program,

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def findN():
    sequence = [[0], [1]]
    sums = [0, 1]
    n = 2
    while ( True ):
        array = []
        for i in xrange( 1, n ):
            x = n - i
            if ( x <= i ):
                array.append( sums[ x ] )
            else:
                s = 0
                for j in xrange( 0, i ):
                    s += sequence[ x ][ j ]
                array.append( s )
        array.append( 1 )
        sequence.append( array )
        sums.append( reduce(lambda x, y: x + y, array) )
        if (n == 45):
            print sums[ -1 ]
            break
        n += 1
findN() #It returns 89134

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...