Revision 6352d3d1-c46c-4607-830d-24c4dbc3d0e6 - Code Golf Stack Exchange

#C++ 99 
 
	#include<iostream>
	int* f(int x){int a[x],i;a[0]=1;for(i=1;i<=x;i++){a[i]=a[i-1]+i+i+1;}return a;} 
 
my first try in code-golf 
 
this code is based on 
a = 2 x n - 1 
where **n** is term count and **a** is **n** th term in the following series 
1, 3, 5, 9, 11, 13, ..... 
sum of first 2 terms = 2 squared 
 
sum of first 3 terms = 3 squared 
and so on...

AltStyle によって変換されたページ (->オリジナル) /