Computer Science, asked by hermoinegranger7, 1 year ago

class 8 output in java
solve the series________________#_#
NO SPAM
dont \: do \: if \: you \: dont \: know

Attachments:

hermoinegranger7: help me out
hermoinegranger7: so what is the logic behind the series
hermoinegranger7: yes sure
hermoinegranger7: I guess u got it by now
hermoinegranger7: oh!ok

Answers

Answered by Anonymous
3

Hi

Finally I solved it!

var range = 8;

var totalOfLastFourNumbers = 0;

var lastFourNumbers = [];

var result = [];


for (var i = 1; i <= range; i++) {

lastFourNumbers.push(i);

result.push(i);

if (lastFourNumbers.length == 4) {

 

 for (var j = 0; j < 4; j++) {

  totalOfLastFourNumbers += lastFourNumbers[j];

 }

 result.push(totalOfLastFourNumbers);

 totalOfLastFourNumbers = 0;

 lastFourNumbers = [];

}

}


document.write(result);

I hope you can convert it in whatever language you want.

Attachments:

hermoinegranger7: which class both of you?
nitish8089: 1 2 3 4 now next is 1+2+3+4=10
hermoinegranger7: I got already thank you
nitish8089: 5 6 7 8 now next 5+6+7+8=26
nitish8089: good luck
nitish8089: @ ajay are you here.
hermoinegranger7: I would be pleased to know both of your classes
nitish8089: pass out school..
Answered by nitish8089
4
code...
public class Program
{
public static void main(String[] args) {

int i=1;

int count=0;

int sum=0;

do{

System.out.print(i+" ");

count++;

sum+=i;

if(count%4==0){

System.out.print(sum+" ");

sum=0;
}

}while(i++<8);

}

}
Attachments:

nitish8089: ok ... gn too late we are..
hermoinegranger7: I am following both of you help me with some programs
nitish8089: ok....
hermoinegranger7: hey in the before java program tell me the logic
hermoinegranger7: of the series
hermoinegranger7: help me out with the questions I have asked
hermoinegranger7: plzzz
hermoinegranger7: lzzzzzzzzzzzz
hermoinegranger7: I need help
Similar questions