The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(49g 50g) Zigzag numbers
10-02-2018, 01:53 PM (This post was last modified: 09-22-2019 02:42 PM by John Keith.)
Post: #1
(49g 50g) Zigzag numbers
The following program returns a list of the Euler zigzag numbers (A000111) from 0 though n. The even-indexed terms (starting with 0) of the list are the unsigned Euler numbers, also known as secant numbers (A000364). The odd-indexed terms (starting with 1) are the tangent numbers, A000182.



Code:

\<< I\->R \-> n
  \<< 1 { 1 } 1. n
    START REVLIST 0 :: + Scanl DUP Last NEWOB SWAP
    NEXT DROP n 1. + \->LIST
  \>>
\>>

The next program returns rows 0 through n of A008281, the triangle from which the zigzag numbers are derived:

Code:

\<< I\->R \-> n
  \<< { 1 } 1. n
    START DUP REVLIST :: + Scanl1 0 SWAP +
    NEXT n 1. + \->LIST
  \>>
\>>

These programs are based on the "Boustrophedon transform", which is detailed in the Links section of the A008281 link above. They requireGoferLists, and should be used in exact mode due to the size of integers involved.

Edited 9/22/2019 to replace the first program with a smaller, faster version.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49g 50g) Zigzag numbers - John Keith - 10-02-2018 01:53 PM



User(s) browsing this thread: 1 Guest(s)