+ 1
hi who can coding for this series 1 3 6 10 15 21 28 .....
coding for this series
6 Respuestas
+ 13
My code in c++
https://code.sololearn.com/cMZw7QxXi1Xu/?ref=app
Input number of elements to be printed at start
+ 9
Formula:
x * (( 0.5x ) + 0.5 )
Where x is the n'th number, starting at 1.
Example:
3 * ((0.5 * 3) + 0.5)
= 3 * (1.5+0.5)
= 3 * 2
= 6
3rd number is 6.
+ 8
https://code.sololearn.com/cF6bjuwJur9A/?ref=app
One possible way
+ 4
Since everyone is posting solutions, here is one using a generator:
https://code.sololearn.com/ccQuCk15J4bf
Nevertheless, you probably should have tried to solve that yourself.
+ 3
int outputs = [];
const arrSize = 100;
for (i=0,a=0;a <arrSize;a++) {
i +=a+1;
outputs [a] = i:
}
+ 2
using C++
#include <iostream>
using namespace std;
int main()
{
int a = 0;
for (int i = 1; i < 100; i++)
{
a += i;
cout << a << " ";
}
system("pause");
return 0;
}
using C#
using System;
namespace soloApp
{
class Program
{
static void Main(string[] args)
{
int a = 0;
for (int i = 1; i < 100; i++)
{
a += i;
Console.Write(a + " ");
}
}
}
}