top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Calculate 1+2+…+n without multiplication?

+4 votes
464 views

Calculate 1+2+…+n without multiplication, division, key words for, while, if, else, switch, case, as well as conditional operator (A ? B : C).

posted Dec 12, 2013 by Anuj Yadav

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
Is addition allowed?

Similar Questions
+2 votes

here is the sample code of problem :
a=100000000,b=200000;
multiplication=1;
while(a--){
multiplication=multiplication*b;
}
printf "multiplication= result"
reduce the time complexity by giving a suitable example which must have less complexity than this for large numbers.

+7 votes

Given two n-node trees, how many rotations does it take to convert one tree into the other?

+3 votes

List => 1 2 3 4 5 6 7 8 9

N=3 Out Put => 1 2 3 6 5 4 7 8 9
N=4 Out Put => 1 2 6 5 4 3 7 8 9
N=5 Out Put => 1 2 7 6 5 4 3 8 9

+4 votes

Give a good data structure for having n queues (n not fixed) in a finite memory segment. You can
have some data-structure separate for each queue. Try to use at least 90% of the memory space.

...