Activity Forums Salesforce® Discussions Error in printing series 1, (1+1)^2= 4, (4+1)^2 =25 upto 10 terms.

  • Error in printing series 1, (1+1)^2= 4, (4+1)^2 =25 upto 10 terms.

    Posted by PRANAV on July 15, 2016 at 2:25 pm

    Error in printing series 1 , (1+1)^2= 4 , (4+1)^2 =25 upto 10 terms.
    Code:

    integer i , n1=1 , n2=1 , n3=2 , n4=1 , count=10;
    for(i=0;i<count;i++)
    {
    n4 = (n1+n2)*(n1+n2);
    System.debug(n1 + ', (' + n1 + '+' + n2 + ')^' + n3 + '=' + n4 + ' , ');
    n1=n4;
    }

     

    Screenshot:series1

    debug in different lines not in a single line . How to debug in a single line like a whole series?

    Ajit replied 7 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Ajit

    Member
    August 10, 2016 at 12:09 pm

    Hi Pranav,

    System.debug(n1 + ‘, (‘ + n1 + ‘+’ + n2 + ‘)^’ + n3 + ‘=’ + n4 + ‘ , ‘);

    it is in for loop use it outside of the loop.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos