[20343 views]
Here in this algorithm we declare four variables as integer, n for storing the number, i for running the for loop, sum for storing the result and t for deciding if its positive(+1) or negative(-1).
Then we read the variable n and run the for loop from i=1 to n*2-1 representing the odd number like if we choose 5 then at the 5th number 9 should be there. And incrementing i by 2 as we need odd numbers we will start form 1 and add 2 to get odd number. Then using the if statement we will check if the number n is less than 0 or not. If yes then print as it is and if no print +i*t .We are doing this only to print the series as positive numbers do not come with + sign. For getting the sum we add sum of previous loop and odd number of this loop. For Eg. Let's take N =3 then loop will run from 1 to 5
hello.thanks for this flowchart. if it is possible please write its algorithm(for example 1-start 2-declare sum,n,t,i 3-read n ....) thanks