javascript - Is there a name for a formula to calculate ascending numbers to a quadratic-like sequence? -


उदाहरण के लिए किसी भी श्रेणी की संख्या 0 - n

[0, 1, 2, 3, 4, 5, 6]

के लिए: < ब्लॉककोट>

[0, 2, 4, 6, 4, 2, 0]

क्या दूसरे में पहली गणना करने के लिए एक सूत्र है? द्विघात? क्या इस प्रकार के सूत्र या गणना का कोई नाम है?

संपादित करें: यह जावास्क्रिप्ट में होना चाहिए

मुझे नहीं पता है कि आप" द्विघात-समान "से क्या कहते हैं, लेकिन निम्नलिखित जावास्क्रिप्ट प्रोग्राम आपके अनुक्रम की तरह दिखाई देने वाला कुछ प्रिंट करता है:

  n = 6; (I = 0; i & lt; = n; i ++) {प्रिंट (i, n-Math.abs (2 * में)}}   

आउटपुट:

  0 0 1 2 2 4 3 6 4 4 5 2 6 0    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -