+ 3
Challenge sequence 5 : 2,7,16,29,46,67,92,121,154.....code it...All languages welcome
All languages welcome...code it
18 Answers
+ 5
Here mine with math formula
https://code.sololearn.com/cNk5v29mvn71/?ref=app
https://code.sololearn.com/cQ55rVPy8TES/?ref=app
+ 18
@Deepak, what do you mean by "hard coded"?
It's all inside the for loop...
+ 16
(2 * n * n - n + 1) is the series generator.
n = 1 => 2 - 1 + 1 = 2
n = 2 => 8 - 2 + 1 = 7
n = 3 => 18 - 3 + 1 = 16 and so on.
+ 4
@krishna Teja, how were you able to get the nth term expression? (2*n^2 - n + 1)
Thanks !
+ 4
https://code.sololearn.com/cn6415CiyWgz/?ref=app
my answerââ c++â€â€
+ 3
+ 2
2 methods...with maths formula
+ 2
Logic part:
for(i=1;i<n;i++)
{
a=(i*i)+i*(i-1)+1
printf("%d",a);
a=0;
}
when i=1: a=1+0+1»2
when i=2: a=4+2+1»7
when i=3: a=9+6+1»17
when i=4: a=16+12+1»29
Thank youđ
+ 1
@sk
if you enter limit 9...only 2 number outputs are printed...logic is ok