-- | The On-Line Encyclopedia of Integer Sequences, <http://oeis.org/>
module Music.Theory.Math.Oeis where

import Data.Bits {- base -}
import Data.Char {- base -}
import Data.List {- base -}
import Data.Ratio {- base -}

import qualified Data.Set as Set {- containers -}

import qualified Data.MemoCombinators as Memo {- data-memocombinators -}

import qualified Music.Theory.Math as Math {- hmt-base -}

import qualified Music.Theory.Math.Prime as Prime {- hmt -}

{- | <http://oeis.org/A000005>

d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. (Formerly M0246 N0086)

[1, 2, 2, 3, 2, 4, 2, 4, 3, 4, 2, 6, 2, 4, 4, 5, 2, 6, 2, 6, 4, 4, 2, 8, 3, 4, 4, 6, 2, 8, 2, 6, 4, 4, 4, 9, 2, 4, 4, 8, 2, 8, 2, 6, 6, 4, 2, 10, 3, 6, 4, 6, 2, 8, 4, 8, 4, 4, 2, 12, 2, 4, 6, 7, 4, 8, 2, 6, 4, 8, 2, 12, 2, 4, 6, 6, 4, 8, 2, 10, 5, 4, 2, 12, 4, 4, 4, 8, 2, 12, 4, 6, 4, 4, 4, 12, 2, 6, 6, 9, 2, 8, 2, 8] `isPrefixOf` a000005
-}
a000005 :: Integral n => [n]
a000005 :: forall n. Integral n => [n]
a000005 = forall a b. (a -> b) -> [a] -> [b]
map (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
+ n
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. Integral n => n -> [n]
a124010_row) [n
1..]

{- | <http://oeis.org/A000010>

Euler totient function phi(n): count numbers <= n and prime to n.

> [1,1,2,2,4,2,6,4,6,4,10,4,12,6,8,8,16,6,18,8,12,10,22,8,20,12] `isPrefixOf` a000010
-}
a000010 :: Integral n => [n]
a000010 :: forall n. Integral n => [n]
a000010 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a000010_n [n
1 ..]

a000010_n :: Integral n => n -> n
a000010_n :: forall n. Integral n => n -> n
a000010_n n
n = forall i a. Num i => [a] -> i
genericLength (forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
==n
1) (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Integral a => a -> a -> a
gcd n
n) [n
1..n
n]))

{- | <http://oeis.org/A000012>

The simplest sequence of positive numbers: the all 1's sequence.
-}
a000012 :: Num n => [n]
a000012 :: forall n. Num n => [n]
a000012 = forall a. a -> [a]
repeat n
1

{- | <https://oeis.org/A000031>

Number of n-bead necklaces with 2 colors when turning over is not allowed; also number of output sequences from a simple n-stage cycling shift register; also number of binary irreducible polynomials whose degree divides n.

> [1,2,3,4,6,8,14,20,36,60,108,188,352,632,1182,2192,4116,7712,14602,27596] `isPrefixOf` a000031
-}
a000031 :: Integral n => [n]
a000031 :: forall n. Integral n => [n]
a000031 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a000031_n [n
0..]

a000031_n :: Integral n => n -> n
a000031_n :: forall n. Integral n => n -> n
a000031_n n
n =
  if n
n forall a. Eq a => a -> a -> Bool
== n
0
  then n
1
  else let divs :: [n]
divs = forall n. Integral n => n -> [n]
a027750_row n
n
       in ((forall a. Integral a => a -> a -> a
`div` n
n) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) (forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a000010_n [n]
divs) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (n
2 forall a b. (Num a, Integral b) => a -> b -> a
^) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
reverse) [n]
divs

{- | <http://oeis.org/A000032>

Lucas numbers beginning at 2: L(n) = L(n-1) + L(n-2), L(0) = 2, L(1) = 1. (Formerly M0155)

> [2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127] `isPrefixOf` a000032
-}
a000032 :: Num n => [n]
a000032 :: forall n. Num n => [n]
a000032 = n
2 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000032 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000032)

{- | <http://oeis.org/A000040>

The prime numbers.

> [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103] `isPrefixOf` a000040
-}
a000040 :: Integral n => [n]
a000040 :: forall n. Integral n => [n]
a000040 =
  let base :: [n]
base = [n
2, n
3, n
5, n
7, n
11, n
13, n
17]
      larger :: [n]
larger = n
p0 forall a. a -> [a] -> [a]
: forall a. (a -> Bool) -> [a] -> [a]
filter n -> Bool
prime [n]
more
      prime :: n -> Bool
prime n
n = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((forall a. Ord a => a -> a -> Bool
> n
0) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Integral a => a -> a -> a
mod n
n) (forall a. (a -> Bool) -> [a] -> [a]
takeWhile (\n
x -> n
xforall a. Num a => a -> a -> a
*n
x forall a. Ord a => a -> a -> Bool
<= n
n) [n]
larger)
      n
_ : n
p0 : [n]
more = forall {a}. (Num a, Enum a) => (a, [a]) -> [a]
roll ([n] -> (n, [n])
makeWheels [n]
base)
      roll :: (a, [a]) -> [a]
roll (a
n,[a]
rs) = [a
n forall a. Num a => a -> a -> a
* a
k forall a. Num a => a -> a -> a
+ a
r | a
k <- [a
0..], a
r <- [a]
rs]
      makeWheels :: [n] -> (n, [n])
makeWheels = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl forall {a}. Integral a => (a, [a]) -> a -> (a, [a])
nextSize (n
1,[n
1])
      nextSize :: (a, [a]) -> a -> (a, [a])
nextSize (a
size,[a]
bs) a
p = (a
size forall a. Num a => a -> a -> a
* a
p,[a
r | a
k <- [a
0..a
pforall a. Num a => a -> a -> a
-a
1], a
b <- [a]
bs, let r :: a
r = a
sizeforall a. Num a => a -> a -> a
*a
kforall a. Num a => a -> a -> a
+a
b, forall a. Integral a => a -> a -> a
mod a
r a
p forall a. Ord a => a -> a -> Bool
> a
0])
  in [n]
base forall a. [a] -> [a] -> [a]
++ [n]
larger

{- | <http://oeis.org/A000041>

a(n) is the number of partitions of n (the partition numbers).

[1,1,2,3,5,7,11,15,22,30,42,56,77,101,135,176,231,297,385,490,627,792,1002,1255] `isPrefixOf` a000041
-}
a000041 :: Num n => [n]
a000041 :: forall n. Num n => [n]
a000041 =
  let p_m :: Integer -> Integer -> n
p_m = forall a b r. Memo a -> Memo b -> (a -> b -> r) -> a -> b -> r
Memo.memo2 forall a. Integral a => Memo a
Memo.integral forall a. Integral a => Memo a
Memo.integral Integer -> Integer -> n
p
      p :: Integer -> Integer -> n
p Integer
_ Integer
0 = n
1
      p Integer
k Integer
m = if Integer
m forall a. Ord a => a -> a -> Bool
< Integer
k then n
0 else Integer -> Integer -> n
p_m Integer
k (Integer
m forall a. Num a => a -> a -> a
- Integer
k) forall a. Num a => a -> a -> a
+ Integer -> Integer -> n
p_m (Integer
k forall a. Num a => a -> a -> a
+ Integer
1) Integer
m
  in forall a b. (a -> b) -> [a] -> [b]
map (Integer -> Integer -> n
p_m Integer
1) [Integer
0::Integer ..]

{- | <http://oeis.org/A000045>

Fibonacci numbers

> [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946] `isPrefixOf` a000045
-}
a000045 :: Num n => [n]
a000045 :: forall n. Num n => [n]
a000045 = n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000045 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000045)

{- | <http://oeis.org/A000051>

a(n) = 2^n + 1

> [2,3,5,9,17,33,65,129,257,513,1025,2049,4097,8193,16385,32769,65537,131073] `isPrefixOf` a000051
-}
a000051 :: Num n => [n]
a000051 :: forall n. Num n => [n]
a000051 = forall a. (a -> a) -> a -> [a]
iterate (forall a. Num a => a -> a -> a
subtract n
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Num a => a -> a -> a
* n
2)) n
2

{- | <http://oeis.org/A000071>

a(n) = Fibonacci(n) - 1.

> [0,0,1,2,4,7,12,20,33,54,88,143,232,376,609,986,1596,2583,4180,6764,10945,17710] `isPrefixOf` a000071
-}
a000071 :: Num n => [n]
a000071 :: forall n. Num n => [n]
a000071 = forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
subtract n
1) (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000045)

{- | <http://oeis.org/A000073>

Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) for n >= 3 with a(0) = a(1) = 0 and a(2) = 1.

> [0,0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890] `isPrefixOf` a000073
-}
a000073 :: Num n => [n]
a000073 :: forall n. Num n => [n]
a000073 = n
0 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000073 (forall a. [a] -> [a]
tail (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000073 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000073)))

{- | <http://oeis.org/A000078>

Tetranacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) + a(n-4) with a(0)=a(1)=a(2)=0, a(3)=1.

> [0,0,0,1,1,2,4,8,15,29,56,108,208,401,773,1490,2872,5536,10671,20569,39648] `isPrefixOf` a000078
-}
a000078 :: Num n => [n]
a000078 :: forall n. Num n => [n]
a000078 =
  let f :: [a] -> [a]
f [a]
xs = let y :: a
y = (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> a
head forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [[a]] -> [[a]]
transpose forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> [a] -> [a]
take Int
4 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [[a]]
tails) [a]
xs in a
y forall a. a -> [a] -> [a]
: [a] -> [a]
f (a
yforall a. a -> [a] -> [a]
:[a]
xs)
  in n
0 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: forall {a}. Num a => [a] -> [a]
f [n
0, n
0, n
0, n
1]

{- | <http://oeis.org/A000079>

Powers of 2: a(n) = 2^n. (Formerly M1129 N0432)

> [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536] `isPrefixOf` a000079
> [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536] `isPrefixOf` map (2 ^) [0..]
-}
a000079 :: Num n => [n]
a000079 :: forall n. Num n => [n]
a000079 = forall a. (a -> a) -> a -> [a]
iterate (forall a. Num a => a -> a -> a
* n
2) n
1

{- | <http://oeis.org/A000085>

Number of self-inverse permutations on n letters, also known as involutions; number of standard Young tableaux with n cells.

> [1,1,2,4,10,26,76,232,764,2620,9496,35696,140152,568504,2390480,10349536] `isPrefixOf` a000085
-}
a000085 :: Integral n => [n]
a000085 :: forall n. Integral n => [n]
a000085 = n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [n
1..] forall n. Integral n => [n]
a000085) (forall a. [a] -> [a]
tail forall n. Integral n => [n]
a000085)

{- | <http://oeis.org/A000108>

Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!).

> [1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845] `isPrefixOf` a000108
-}
a000108 :: Num n => [n]
a000108 :: forall n. Num n => [n]
a000108 = forall a b. (a -> b) -> [a] -> [b]
map forall a. [a] -> a
last (forall a. (a -> a) -> a -> [a]
iterate (forall a. (a -> a -> a) -> [a] -> [a]
scanl1 forall a. Num a => a -> a -> a
(+) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. [a] -> [a] -> [a]
++ [n
0])) [n
1])

{- | <http://oeis.org/A000120>

1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).

> [0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3] `isPrefixOf` a000120
-}
a000120 :: Integral i => [i]
a000120 :: forall n. Integral n => [n]
a000120 = let r :: [[i]]
r = [i
0] forall a. a -> [a] -> [a]
: (forall a b. (a -> b) -> [a] -> [b]
map forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map) (forall a. Num a => a -> a -> a
+ i
1) (forall a. (a -> a -> a) -> [a] -> [a]
scanl1 forall a. [a] -> [a] -> [a]
(++) [[i]]
r) in forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[i]]
r

{- | <http://oeis.org/A000142>

Factorial numbers: n! = 1*2*3*4*...*n
(order of symmetric group S_n, number of permutations of n letters).

> [1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800] `isPrefixOf` a000142
-}
a000142 :: (Enum n, Num n) => [n]
a000142 :: forall n. (Enum n, Num n) => [n]
a000142 = n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [n
1..] forall n. (Enum n, Num n) => [n]
a000142

{- | https://oeis.org/A000201

Lower Wythoff sequence (a Beatty sequence): a(n) = floor(n*phi), where phi = (1+sqrt(5))/2 = A001622

> [1,3,4,6,8,9,11,12,14,16,17,19,21,22,24,25,27,29,30,32,33,35,37,38,40,42] `isPrefixOf` a000201

> import Sound.SC3.Plot {- hsc3-plot -}
> plot_p1_imp [take 128 a000201 :: [Int]]
-}
a000201 :: Integral n => [n]
a000201 :: forall n. Integral n => [n]
a000201 =
  let f :: [a] -> [a] -> [a]
f (a
x:[a]
xs) (a
y:[a]
ys) = a
y forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
f [a]
xs (forall a. Eq a => a -> [a] -> [a]
delete (a
x forall a. Num a => a -> a -> a
+ a
y) [a]
ys)
      f [a]
_ [a]
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"a000201"
  in forall {a}. (Eq a, Num a) => [a] -> [a] -> [a]
f [n
1..] [n
1..]

{- | <https://oeis.org/A000204>

Lucas numbers (beginning with 1): L(n) = L(n-1) + L(n-2) with L(1) = 1, L(2) = 3

> [1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127] `isPrefixOf` a000204
-}
a000204 :: Num n => [n]
a000204 :: forall n. Num n => [n]
a000204 = n
1 forall a. a -> [a] -> [a]
: n
3 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000204 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000204)

{- | <http://oeis.org/A000213>

Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) with a(0)=a(1)=a(2)=1.

[1,1,1,3,5,9,17,31,57,105,193,355,653,1201,2209,4063,7473,13745,25281,46499]  `isPrefixOf` a000213
-}
a000213 :: Num n => [n]
a000213 :: forall n. Num n => [n]
a000213 = n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000213 (forall a. [a] -> [a]
tail (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000213 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000213)))

{- | <https://oeis.org/A000217>

Triangular numbers: a(n) = binomial(n+1,2) = n(n+1)/2 = 0 + 1 + 2 + ... + n.

> [0,1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210,231,253,276] `isPrefixOf` a000217
-}
a000217 :: (Enum n,Num n) => [n]
a000217 :: forall n. (Enum n, Num n) => [n]
a000217 = forall a. (a -> a -> a) -> [a] -> [a]
scanl1 forall a. Num a => a -> a -> a
(+) [n
0..]

{- | <http://oeis.org/A000225>

a(n) = 2^n - 1 (Sometimes called Mersenne numbers, although that name is usually reserved for A001348)

> [0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535] `isPrefixOf` a000225
-}
a000225 :: Num n => [n]
a000225 :: forall n. Num n => [n]
a000225 = forall a. (a -> a) -> a -> [a]
iterate ((forall a. Num a => a -> a -> a
+ n
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Num a => a -> a -> a
* n
2)) n
0

{- | <http://oeis.org/000285>

a(0) = 1, a(1) = 4, and a(n) = a(n-1) + a(n-2) for n >= 2. (Formerly M3246 N1309)

> [1,4,5,9,14,23,37,60,97,157,254,411,665,1076,1741,2817,4558,7375,11933,19308] `isPrefixOf` a000285
-}
a000285 :: Num n => [n]
a000285 :: forall n. Num n => [n]
a000285 = n
1 forall a. a -> [a] -> [a]
: n
4 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000285 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000285)

{- | <http://oeis.org/A000290>

The squares of the non-negative integers.

> [0,1,4,9,16,25,36,49,64,81,100] `isPrefixOf` a000290
-}
a000290 :: Integral n => [n]
a000290 :: forall n. Integral n => [n]
a000290 = let square :: a -> a
square a
n = a
n forall a. Num a => a -> a -> a
* a
n in forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => a -> a
square [n
0..]

{- | <https://oeis.org/A000292>

Tetrahedral (or triangular pyramidal) numbers: a(n) = C(n+2,3) = n*(n+1)*(n+2)/6.

> [0,1,4,10,20,35,56,84,120,165,220,286,364,455,560,680,816,969,1140,1330,1540] `isPrefixOf` a000292
-}
a000292 :: (Enum n,Num n) => [n]
a000292 :: forall n. (Enum n, Num n) => [n]
a000292 = forall a. (a -> a -> a) -> [a] -> [a]
scanl1 forall a. Num a => a -> a -> a
(+) forall n. (Enum n, Num n) => [n]
a000217

{- | <http://oeis.org/A000384>

Hexagonal numbers: a(n) = n*(2*n-1). (Formerly M4108 N1705)

> [0,1,6,15,28,45,66,91,120,153,190,231,276,325,378,435,496,561,630,703,780,861] `isPrefixOf` a000384
-}
a000384 :: Integral n => [n]
a000384 :: forall n. Integral n => [n]
a000384 = forall b a. (b -> a -> b) -> b -> [a] -> [b]
scanl forall a. Num a => a -> a -> a
(+) n
0 forall n. Integral n => [n]
a016813

{- | <http://oeis.org/A000578>

The cubes: a(n) = n^3.

> [0,1,8,27,64,125,216,343,512,729,1000,1331,1728,2197,2744,3375,4096,4913,5832] `isPrefixOf` a000578
-}
a000578 :: Num n => [n]
a000578 :: forall n. Num n => [n]
a000578 =
  n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
8 forall a. a -> [a] -> [a]
:
  forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
+ n
6) forall n. Num n => [n]
a000578) (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
* n
3) (forall a. [a] -> [a]
tail (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (-) (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000578) forall n. Num n => [n]
a000578)))

{- | <http://oeis.org/A000583>

Fourth powers: a(n) = n^4.

> [0,1,16,81,256,625,1296,2401,4096,6561,10000,14641,20736,28561,38416,50625] `isPrefixOf` a000583
-}
a000583 :: Integral n => [n]
a000583 :: forall n. Integral n => [n]
a000583 = forall b a. (b -> a -> b) -> b -> [a] -> [b]
scanl forall a. Num a => a -> a -> a
(+) n
0 forall n. Integral n => [n]
a005917

{- | <http://oeis.org/A000670>

Fubini numbers: number of preferential arrangements of n labeled elements; or number of weak orders on n labeled elements; or number of ordered partitions of [n].

> [1,1,3,13,75,541,4683,47293,545835,7087261,102247563,1622632573,28091567595] `isPrefixOf` a000670
-}
a000670 :: Integral n => [n]
a000670 :: forall n. Integral n => [n]
a000670 =
  let f :: [a] -> [[a]] -> [a]
f [a]
xs ([a]
bs:[[a]]
bss) = let y :: a
y = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [a]
xs [a]
bs) in a
y forall a. a -> [a] -> [a]
: [a] -> [[a]] -> [a]
f (a
y forall a. a -> [a] -> [a]
: [a]
xs) [[a]]
bss
      f [a]
_ [[a]]
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"a000670d"
  in n
1 forall a. a -> [a] -> [a]
: forall {a}. Num a => [a] -> [[a]] -> [a]
f [n
1] (forall a b. (a -> b) -> [a] -> [b]
map forall a. [a] -> [a]
tail (forall a. [a] -> [a]
tail forall i. Integral i => [[i]]
a007318_tbl))

{- | <https://oeis.org/A000796>

Decimal expansion of Pi (or digits of Pi).

> [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0,2,8,8,4,1,9] `isPrefixOf` a000796

> pi :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 {- numbers -}
-}
a000796 :: Integral n => [n]
a000796 :: forall n. Integral n => [n]
a000796 =
  let gen :: (a, a, a) -> [(a, a, a)] -> [a]
gen (a, a, a)
_ [] = forall a. HasCallStack => [Char] -> a
error [Char]
"A000796"
      gen (a, a, a)
z ((a, a, a)
x:[(a, a, a)]
xs) =
        let lb :: a
lb = forall {a}. Integral a => (a, a, a) -> a -> a
approx (a, a, a)
z a
3
            approx :: (a, a, a) -> a -> a
approx (a
a,a
b,a
c) a
n = forall a. Integral a => a -> a -> a
div (a
a forall a. Num a => a -> a -> a
* a
n forall a. Num a => a -> a -> a
+ a
b) a
c
            mult :: (c, c, c) -> (c, c, c) -> (c, c, c)
mult (c
a,c
b,c
c) (c
d,c
e,c
f) = (c
a forall a. Num a => a -> a -> a
* c
d,c
a forall a. Num a => a -> a -> a
* c
e forall a. Num a => a -> a -> a
+ c
b forall a. Num a => a -> a -> a
* c
f,c
c forall a. Num a => a -> a -> a
* c
f)
        in if a
lb forall a. Eq a => a -> a -> Bool
/= forall {a}. Integral a => (a, a, a) -> a -> a
approx (a, a, a)
z a
4
           then (a, a, a) -> [(a, a, a)] -> [a]
gen (forall {c}. Num c => (c, c, c) -> (c, c, c) -> (c, c, c)
mult (a, a, a)
z (a, a, a)
x) [(a, a, a)]
xs
        else a
lb forall a. a -> [a] -> [a]
: (a, a, a) -> [(a, a, a)] -> [a]
gen (forall {c}. Num c => (c, c, c) -> (c, c, c) -> (c, c, c)
mult (a
10,-a
10 forall a. Num a => a -> a -> a
* a
lb,a
1) (a, a, a)
z) ((a, a, a)
xforall a. a -> [a] -> [a]
:[(a, a, a)]
xs)
  in forall a b. (a -> b) -> [a] -> [b]
map forall a. Num a => Integer -> a
fromInteger (forall {a}. Integral a => (a, a, a) -> [(a, a, a)] -> [a]
gen (Integer
1,Integer
0,Integer
1) [(Integer
n,Integer
aforall a. Num a => a -> a -> a
*Integer
d,Integer
d) | (Integer
n,Integer
d,Integer
a) <- forall a b. (a -> b) -> [a] -> [b]
map (\Integer
k -> (Integer
k,Integer
2 forall a. Num a => a -> a -> a
* Integer
k forall a. Num a => a -> a -> a
+ Integer
1,Integer
2)) [Integer
1..]])

{- | <https://oeis.org/A000930>

Narayana's cows sequence.

> [1,1,1,2,3,4,6,9,13,19,28,41,60] `isPrefixOf` a000930
-}
a000930 :: Num n => [n]
a000930 :: forall n. Num n => [n]
a000930 = n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000930 (forall a. Int -> [a] -> [a]
drop Int
2 forall n. Num n => [n]
a000930)

{- | <https://oeis.org/A000931>

Padovan sequence (or Padovan numbers): a(n) = a(n-2) + a(n-3) with a(0) = 1, a(1) = a(2) = 0.

> [1,0,0,1,0,1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151,200,265] `isPrefixOf` a000931
-}
a000931 :: Num n => [n]
a000931 :: forall n. Num n => [n]
a000931 = n
1 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a000931 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000931)

{- | <https://oeis.org/A001008>

Numerators of harmonic numbers H(n) = Sum_{i=1..n} 1/i

[1,3,11,25,137,49,363,761,7129,7381,83711,86021,1145993,1171733,1195757,2436559] `isPrefixOf` a001008
-}
a001008 :: Integral i => [i]
a001008 :: forall n. Integral n => [n]
a001008 = forall a b. (a -> b) -> [a] -> [b]
map forall a. Ratio a -> a
numerator (forall a. (a -> a -> a) -> [a] -> [a]
scanl1 forall a. Num a => a -> a -> a
(+) (forall a b. (a -> b) -> [a] -> [b]
map (i
1 forall a. Integral a => a -> a -> Ratio a
%) [i
1..]))

{- | <http://oeis.org/A001037>

Number of degree-n irreducible polynomials over GF(2); number of
n-bead necklaces with beads of 2 colors when turning over is not
allowed and with primitive period n; number of binary Lyndon words of
length n.

> [1,2,1,2,3,6,9,18,30,56,99,186,335,630,1161,2182,4080,7710,14532,27594,52377,99858,190557,364722,698870] `isPrefixOf` a001037
-}
a001037 :: Integral n => [n]
a001037 :: forall n. Integral n => [n]
a001037 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a001037_n [n
0..]

a001037_n :: Integral n => n -> n
a001037_n :: forall n. Integral n => n -> n
a001037_n n
n = if n
n forall a. Eq a => a -> a -> Bool
== n
0 then n
1 else (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map (\n
d -> (n
2 forall a b. (Num a, Integral b) => a -> b -> a
^ n
d) forall a. Num a => a -> a -> a
* forall n. Integral n => n -> n
a008683_n (n
n forall a. Integral a => a -> a -> a
`div` n
d)) (forall n. Integral n => n -> [n]
a027750_row n
n))) forall a. Integral a => a -> a -> a
`div` n
n

{- | <http://oeis.org/A001113>

Decimal expansion of e.

> [2,7,1,8,2,8,1,8,2,8,4,5,9,0,4,5,2,3,5,3,6,0,2,8,7,4,7,1,3,5,2,6,6,2,4,9,7,7,5] `isPrefixOf` a001113

> exp 1 :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 {- numbers -}
-}
a001113 :: Integral n => [n]
a001113 :: forall n. Integral n => [n]
a001113 =
  let gen :: (a, a, a) -> [(a, a, a)] -> [a]
gen (a, a, a)
_ [] = forall a. HasCallStack => [Char] -> a
error [Char]
"A001113"
      gen (a, a, a)
z ((a, a, a)
x:[(a, a, a)]
xs) =
        let lb :: a
lb = forall {a}. Integral a => (a, a, a) -> a -> a
approx (a, a, a)
z a
1
            approx :: (a, a, a) -> a -> a
approx (a
a,a
b,a
c) a
n = forall a. Integral a => a -> a -> a
div (a
a forall a. Num a => a -> a -> a
* a
n forall a. Num a => a -> a -> a
+ a
b) a
c
            mult :: (c, c, c) -> (c, c, c) -> (c, c, c)
mult (c
a,c
b,c
c) (c
d,c
e,c
f) = (c
a forall a. Num a => a -> a -> a
* c
d,c
a forall a. Num a => a -> a -> a
* c
e forall a. Num a => a -> a -> a
+ c
b forall a. Num a => a -> a -> a
* c
f,c
c forall a. Num a => a -> a -> a
* c
f)
        in if a
lb forall a. Eq a => a -> a -> Bool
/= forall {a}. Integral a => (a, a, a) -> a -> a
approx (a, a, a)
z a
2
           then (a, a, a) -> [(a, a, a)] -> [a]
gen (forall {c}. Num c => (c, c, c) -> (c, c, c) -> (c, c, c)
mult (a, a, a)
z (a, a, a)
x) [(a, a, a)]
xs
           else a
lb forall a. a -> [a] -> [a]
: (a, a, a) -> [(a, a, a)] -> [a]
gen (forall {c}. Num c => (c, c, c) -> (c, c, c) -> (c, c, c)
mult (a
10,-a
10 forall a. Num a => a -> a -> a
* a
lb,a
1) (a, a, a)
z) ((a, a, a)
xforall a. a -> [a] -> [a]
:[(a, a, a)]
xs)
  in forall {a}. Integral a => (a, a, a) -> [(a, a, a)] -> [a]
gen (n
1,n
0,n
1) [(n
n,n
a forall a. Num a => a -> a -> a
* n
d,n
d) | (n
n,n
d,n
a) <- forall a b. (a -> b) -> [a] -> [b]
map (\n
k -> (n
1,n
k,n
1)) [n
1..]]

{- | <https://oeis.org/A001147>

Double factorial of odd numbers: a(n) = (2*n-1)!! = 1*3*5*...*(2*n-1). (Formerly M3002 N1217)

> [1,1,3,15,105,945,10395,135135,2027025,34459425,654729075,13749310575] `isPrefixOf` a001147
-}
a001147 :: Integral t => [t]
a001147 :: forall n. Integral n => [n]
a001147 = t
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [t
1, t
3 ..] forall n. Integral n => [n]
a001147

{- | <https://oeis.org/A001156>

Number of partitions of n into squares.

> [1,1,1,1,2,2,2,2,3,4,4,4,5,6,6,6,8,9,10,10,12,13,14,14,16,19,20,21,23,26,27,28] `isPrefixOf` a001156
-}
a001156 :: Num n => [n]
a001156 :: forall n. Num n => [n]
a001156 =
  let p :: [t] -> t -> a
p [t]
_ t
0 = a
1
      p ks' :: [t]
ks'@(t
k:[t]
ks) t
m = if t
m forall a. Ord a => a -> a -> Bool
< t
k then a
0 else [t] -> t -> a
p [t]
ks' (t
m forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
+ [t] -> t -> a
p [t]
ks t
m
      p [t]
_ t
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"A001156"
  in forall a b. (a -> b) -> [a] -> [b]
map (forall {t} {a}. (Num t, Num a, Ord t) => [t] -> t -> a
p (forall a. [a] -> [a]
tail forall n. Integral n => [n]
a000290)) [Integer
0::Integer ..]

{- | <https://oeis.org/A001333>

Numerators of continued fraction convergents to sqrt(2).

[1,1,3,7,17,41,99,239,577,1393,3363,8119,19601,47321,114243,275807,665857] `isPrefixOf` a001333
-}
a001333 :: Num n => [n]
a001333 :: forall n. Num n => [n]
a001333 = n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a001333 (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
* n
2) (forall a. [a] -> [a]
tail forall n. Num n => [n]
a001333))

{- | <http://oeis.org/A001622>

Decimal expansion of golden ratio phi (or tau) = (1 + sqrt(5))/2.

> [1,6,1,8,0,3,3,9,8,8,7,4,9,8,9,4,8,4,8,2,0,4,5,8,6,8,3,4,3,6,5,6,3,8,1,1,7,7,2] `isPrefixOf` a001622

> a001622_k :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 {- numbers -}
-}
a001622 :: Num n => [n]
a001622 :: forall n. Num n => [n]
a001622 = forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
digitToInt) [Char]
"161803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408807538689175212663386222353693179318006076672635443338908659593958290563832266131992829026788067520876689250171169620703222104321626954862629631361443814975870122034080588795445474924618569536486444924104432077134494704956584678850987433944221254487706647809158846074998871240076521705751797883416625624940758906970400028121042762177111777805315317141011704666599146697987317613560067087480711" forall a. [a] -> [a] -> [a]
++ forall a. HasCallStack => [Char] -> a
error [Char]
"A001622"

a001622_k :: Floating n => n
a001622_k :: forall n. Floating n => n
a001622_k = (n
1 forall a. Num a => a -> a -> a
+ forall a. Floating a => a -> a
sqrt n
5) forall a. Fractional a => a -> a -> a
/ n
2

{- |  <http://oeis.org/A001644>

a(n) = a(n-1) + a(n-2) + a(n-3), a(0)=3, a(1)=1, a(2)=3.

[3,1,3,7,11,21,39,71,131,241,443,815,1499,2757,5071,9327,17155,31553,58035,106743] `isPrefixOf` a001644
-}
a001644 :: Num n => [n]
a001644 :: forall n. Num n => [n]
a001644 = n
3 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
3 forall a. a -> [a] -> [a]
: forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith3 ((forall a. Num a => a -> a -> a
(+) forall b c a. (b -> c) -> (a -> b) -> a -> c
.) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => a -> a -> a
(+)) forall n. Num n => [n]
a001644 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a001644) (forall a. Int -> [a] -> [a]
drop Int
2 forall n. Num n => [n]
a001644)

{- | <https://oeis.org/A001653>

Numbers k such that 2*k^2 - 1 is a square.

> [1, 5, 29, 169, 985, 5741, 33461, 195025, 1136689, 6625109, 38613965, 225058681, 1311738121, 7645370045, 44560482149] `isPrefixOf` a001653

-}
a001653 :: [Integer]
a001653 :: [Integer]
a001653 = Integer
1 forall a. a -> [a] -> [a]
: Integer
5 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (-) (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
* Integer
6) (forall a. [a] -> [a]
tail [Integer]
a001653)) [Integer]
a001653

{- | <http://oeis.org/A001687>

a(n) = a(n-2) + a(n-5).

[0,1,0,1,0,1,1,1,2,1,3,2,4,4,5,7,7,11,11,16,18,23,29,34,45,52,68,81,102,126,154] `isPrefixOf` a001687
-}
a001687 :: Num n => [n]
a001687 :: forall n. Num n => [n]
a001687 = n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a001687 (forall a. Int -> [a] -> [a]
drop Int
3 forall n. Num n => [n]
a001687)

{- | <https://oeis.org/A001950>

Upper Wythoff sequence (a Beatty sequence): a(n) = floor(n*phi^2), where phi = (1+sqrt(5))/2

> [2,5,7,10,13,15,18,20,23,26,28,31,34,36,39,41,44,47,49,52,54,57,60,62,65] `isPrefixOf` a001950
-}
a001950 :: Integral n => [n]
a001950 :: forall n. Integral n => [n]
a001950 = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Integral n => [n]
a000201 [n
1..]

-- | <http://oeis.org/A002267>
--
-- The 15 supersingular primes.
a002267 :: Num n => [n]
a002267 :: forall n. Num n => [n]
a002267 = [n
2, n
3, n
5, n
7, n
11, n
13, n
17, n
19, n
23, n
29, n
31, n
41, n
47, n
59, n
71]

{- | <https://oeis.org/A002487>

Stern's diatomic series (or Stern-Brocot sequence)

> [0,1,1,2,1,3,2,3,1,4,3,5,2,5,3,4,1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5] `isPrefixOf` a002487
-}
a002487 :: Num n => [n]
a002487 :: forall n. Num n => [n]
a002487 =
  let f :: [a] -> [a] -> [a]
f (a
a:[a]
a') (a
b:[a]
b') = a
a forall a. Num a => a -> a -> a
+ a
b forall a. a -> [a] -> [a]
: a
a forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
f [a]
a' [a]
b'
      f [a]
_ [a]
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"a002487"
      x :: [n]
x = n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall {a}. Num a => [a] -> [a] -> [a]
f (forall a. [a] -> [a]
tail [n]
x) [n]
x
  in n
0 forall a. a -> [a] -> [a]
: [n]
x

{- | <https://oeis.org/A002858>

Ulam numbers: a(1) = 1; a(2) = 2; for n>2, a(n) = least number > a(n-1) which is a unique sum of two distinct earlier terms.

> [1, 2, 3, 4, 6, 8, 11, 13, 16, 18, 26, 28, 36, 38, 47, 48, 53, 57, 62, 69, 72, 77, 82, 87, 97, 99, 102, 106, 114, 126] `isPrefixOf` a002858
-}
a002858 :: [Integer]
a002858 :: [Integer]
a002858 = Integer
1 forall a. a -> [a] -> [a]
: Integer
2 forall a. a -> [a] -> [a]
: Int -> Integer -> [Integer] -> [Integer]
ulam Int
2 Integer
2 [Integer]
a002858

ulam :: Int -> Integer -> [Integer] -> [Integer]
ulam :: Int -> Integer -> [Integer] -> [Integer]
ulam Int
n Integer
u [Integer]
us =
  let u' :: Integer
u' = forall {t}. (Eq t, Num t) => t -> Integer -> [Integer] -> Integer
f (Integer
0 :: Integer) (Integer
u forall a. Num a => a -> a -> a
+ Integer
1) [Integer]
us'
      f :: t -> Integer -> [Integer] -> Integer
f t
2 Integer
z [Integer]
_                         = t -> Integer -> [Integer] -> Integer
f t
0 (Integer
z forall a. Num a => a -> a -> a
+ Integer
1) [Integer]
us'
      f t
e Integer
z (Integer
v:[Integer]
vs) | Integer
z forall a. Num a => a -> a -> a
- Integer
v forall a. Ord a => a -> a -> Bool
<= Integer
v       = if t
e forall a. Eq a => a -> a -> Bool
== t
1 then Integer
z else t -> Integer -> [Integer] -> Integer
f t
0 (Integer
z forall a. Num a => a -> a -> a
+ Integer
1) [Integer]
us'
                   | Integer
z forall a. Num a => a -> a -> a
- Integer
v forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Integer]
us' = t -> Integer -> [Integer] -> Integer
f (t
e forall a. Num a => a -> a -> a
+ t
1) Integer
z [Integer]
vs
                   | Bool
otherwise        = t -> Integer -> [Integer] -> Integer
f t
e Integer
z [Integer]
vs
      f t
_ Integer
_ []                        = forall a. HasCallStack => [Char] -> a
error [Char]
"ulam?"
      us' :: [Integer]
us' = forall a. Int -> [a] -> [a]
take Int
n [Integer]
us
  in Integer
u' forall a. a -> [a] -> [a]
: Int -> Integer -> [Integer] -> [Integer]
ulam (Int
n forall a. Num a => a -> a -> a
+ Int
1) Integer
u' [Integer]
us

{- | <http://oeis.org/A003108>

Number of partitions of n into cubes.

> [1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,5,5,5,5,5,6,6,6,7,7,7,7] `isPrefixOf` a003108
-}
a003108 :: Num n => [n]
a003108 :: forall n. Num n => [n]
a003108 =
  let p :: [t] -> t -> a
p [t]
_ t
0 = a
1
      p ks' :: [t]
ks'@(t
k:[t]
ks) t
m = if t
m forall a. Ord a => a -> a -> Bool
< t
k then a
0 else [t] -> t -> a
p [t]
ks' (t
m forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
+ [t] -> t -> a
p [t]
ks t
m
      p [t]
_ t
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"A003108"
  in forall a b. (a -> b) -> [a] -> [b]
map (forall {t} {a}. (Num t, Num a, Ord t) => [t] -> t -> a
p (forall a. [a] -> [a]
tail forall n. Num n => [n]
a000578)) [Integer
0::Integer ..]

a003215_n :: Num n => n -> n
a003215_n :: forall {a}. Num a => a -> a
a003215_n n
n = n
3 forall a. Num a => a -> a -> a
* n
n forall a. Num a => a -> a -> a
* (n
n forall a. Num a => a -> a -> a
+ n
1) forall a. Num a => a -> a -> a
+ n
1

{- | <http://oeis.org/A003215>

Hex (or centered hexagonal) numbers: 3*n*(n+1)+1 (crystal ball sequence for hexagonal lattice).

> [1,7,19,37,61,91,127,169,217,271,331,397,469,547,631,721,817,919,1027,1141] `isPrefixOf` a003215
-}
a003215 :: (Enum n,Num n) => [n]
a003215 :: forall n. (Enum n, Num n) => [n]
a003215 = forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => a -> a
a003215_n [n
0..]

-- | <http://oeis.org/A003269>
--
-- > [0,1,1,1,1,2,3,4,5,7,10,14,19,26,36,50,69,95,131,181,250,345,476,657] `isPrefixOf` a003269
a003269 :: Num n => [n]
a003269 :: forall n. Num n => [n]
a003269 = n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a003269 (forall a. Int -> [a] -> [a]
drop Int
3 forall n. Num n => [n]
a003269)

{- | <http://oeis.org/A003520>

a(n) = a(n-1) + a(n-5); a(0) = ... = a(4) = 1.

> [1,1,1,1,1,2,3,4,5,6,8,11,15,20,26,34,45,60,80,106,140,185,245,325,431] `isPrefixOf` a003520
-}
a003520 :: Num n => [n]
a003520 :: forall n. Num n => [n]
a003520 = n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a003520 (forall a. Int -> [a] -> [a]
drop Int
4 forall n. Num n => [n]
a003520)

{- | <http://oeis.org/A003462>

a(n) = (3^n - 1)/2. (Formerly M3463)

[0, 1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161, 2391484, 7174453] `isPrefixOf` a003462
-}
a003462 :: [Integer]
a003462 :: [Integer]
a003462 = forall a. (a -> a) -> a -> [a]
iterate ((forall a. Num a => a -> a -> a
+ Integer
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Num a => a -> a -> a
* Integer
3)) Integer
0

a003462_n :: Integer -> Integer
a003462_n :: Integer -> Integer
a003462_n = (forall a. Integral a => a -> a -> a
`div` Integer
2) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Num a => a -> a -> a
subtract Integer
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer
3 forall a b. (Num a, Integral b) => a -> b -> a
^)

{- | <http://oeis.org/A003586>

3-smooth numbers: numbers of the form 2^i*3^j with i, j >= 0

[1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162] `isPrefixOf` a003586
-}
a003586 :: [Integer]
a003586 :: [Integer]
a003586 =
  let smooth :: Set a -> [a]
smooth Set a
s = let (a
x, Set a
s') = forall a. Set a -> (a, Set a)
Set.deleteFindMin Set a
s in a
x forall a. a -> [a] -> [a]
: Set a -> [a]
smooth (forall a. Ord a => a -> Set a -> Set a
Set.insert (a
3 forall a. Num a => a -> a -> a
* a
x) (forall a. Ord a => a -> Set a -> Set a
Set.insert (a
2 forall a. Num a => a -> a -> a
* a
x) Set a
s'))
  in  forall {a}. (Ord a, Num a) => Set a -> [a]
smooth (forall a. a -> Set a
Set.singleton Integer
1)

{- | <https://oeis.org/A003849>

The infinite Fibonacci word (start with 0, apply 0->01, 1->0, take limit).

> [0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0] `isPrefixOf` a003849
-}
a003849 :: Num n => [n]
a003849 :: forall n. Num n => [n]
a003849 =
  let fws :: [[n]]
fws = [n
1] forall a. a -> [a] -> [a]
: [n
0] forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. [a] -> [a] -> [a]
(++) [[n]]
fws (forall a. [a] -> [a]
tail [[n]]
fws)
  in forall a. [a] -> [a]
tail (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[n]]
fws)

{- | <http://oeis.org/A004001>

Hofstadter-Conway sequence: a(n) = a(a(n-1)) + a(n-a(n-1)) with a(1) = a(2) = 1.

> [1,1,2,2,3,4,4,4,5,6,7,7,8,8,8,8,9,10,11,12,12,13,14,14,15,15,15,16,16,16,16,16] `isPrefixOf` a004001

> plot_p1_ln [take 250 a004001]
> plot_p1_ln [zipWith (-) a004001 (map (`div` 2) [1 .. 2000])]

-}
a004001 :: [Int]
a004001 :: [Int]
a004001 =
  let h :: Int -> Int -> [Int]
h Int
n Int
x =
        let x' :: Int
x' = [Int]
a004001 forall a. [a] -> Int -> a
!! (Int
x forall a. Num a => a -> a -> a
- Int
1) forall a. Num a => a -> a -> a
+ [Int]
a004001 forall a. [a] -> Int -> a
!! (Int
n forall a. Num a => a -> a -> a
- Int
x forall a. Num a => a -> a -> a
- Int
1)
        in Int
x' forall a. a -> [a] -> [a]
: Int -> Int -> [Int]
h (Int
n forall a. Num a => a -> a -> a
+ Int
1) Int
x'
  in Int
1 forall a. a -> [a] -> [a]
: Int
1 forall a. a -> [a] -> [a]
: Int -> Int -> [Int]
h Int
3 Int
1

{- | <http://oeis.org/A004718>

Per Nørgård's "infinity sequence"

> take 32 a004718 == [0,1,-1,2,1,0,-2,3,-1,2,0,1,2,-1,-3,4,1,0,-2,3,0,1,-1,2,-2,3,1,0,3,-2,-4,5]

> plot_p1_imp [take 1024 a004718]

<https://www.tandfonline.com/doi/abs/10.1080/17459737.2017.1299807>
<https://arxiv.org/pdf/1402.3091.pdf>

-}
a004718 :: Num n => [n]
a004718 :: forall n. Num n => [n]
a004718 = n
0 forall a. a -> [a] -> [a]
: forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. [[a]] -> [[a]]
transpose [forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
+ n
1) forall n. Num n => [n]
a004718, forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => a -> a
negate (forall a. [a] -> [a]
tail forall n. Num n => [n]
a004718)])

{- | <http://oeis.org/A005185>

Hofstadter Q-sequence: a(1) = a(2) = 1; a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2.

> [1,1,2,3,3,4,5,5,6,6,6,8,8,8,10,9,10,11,11,12,12,12,12,16,14,14,16,16,16,16,20] `isPrefixOf` a005185
-}
a005185 :: [Int]
a005185 :: [Int]
a005185 =
  let ix :: Int -> Int
ix Int
n = [Int]
a005185 forall a. [a] -> Int -> a
!! (Int
n forall a. Num a => a -> a -> a
- Int
1)
      zadd :: [Int] -> [Int] -> [Int]
zadd = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+)
      zsub :: [Int] -> [Int] -> [Int]
zsub = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (-)
  in Int
1 forall a. a -> [a] -> [a]
: Int
1 forall a. a -> [a] -> [a]
: [Int] -> [Int] -> [Int]
zadd (forall a b. (a -> b) -> [a] -> [b]
map Int -> Int
ix ([Int] -> [Int] -> [Int]
zsub [Int
3..] [Int]
a005185)) (forall a b. (a -> b) -> [a] -> [b]
map Int -> Int
ix ([Int] -> [Int] -> [Int]
zsub [Int
3..] (forall a. [a] -> [a]
tail [Int]
a005185)))

{- | <https://oeis.org/A005448>

Centered triangular numbers: a(n) = 3n(n-1)/2 + 1.

> [1,4,10,19,31,46,64,85,109,136,166,199,235,274,316,361,409,460,514,571,631,694] `isPrefixOf` a005448

> map a005448_n [1 .. 1000] `isPrefixOf` a005448
-}
a005448 :: Integral n => [n]
a005448 :: forall n. Integral n => [n]
a005448 = n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Integral n => [n]
a005448 [n
3,n
6 ..]

a005448_n :: Integral n => n -> n
a005448_n :: forall n. Integral n => n -> n
a005448_n n
n = n
3 forall a. Num a => a -> a -> a
* n
n forall a. Num a => a -> a -> a
* (n
n forall a. Num a => a -> a -> a
- n
1) forall a. Integral a => a -> a -> a
`div` n
2 forall a. Num a => a -> a -> a
+ n
1

{- | <http://oeis.org/A005728>

Number of fractions in Farey series of order n.

> [1,2,3,5,7,11,13,19,23,29,33,43,47,59,65,73,81,97,103,121,129,141,151] `isPrefixOf` a005728
-}
a005728 :: Integral i => [i]
a005728 :: forall n. Integral n => [n]
a005728 =
  let phi :: a -> i
phi a
n = forall i a. Num i => [a] -> i
genericLength (forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
==a
1) (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Integral a => a -> a -> a
gcd a
n) [a
1..a
n]))
      f :: a -> a
f a
n = if a
n forall a. Eq a => a -> a -> Bool
== a
0 then a
1 else a -> a
f (a
n forall a. Num a => a -> a -> a
- a
1) forall a. Num a => a -> a -> a
+ forall {a} {i}. (Num i, Integral a) => a -> i
phi a
n
  in forall a b. (a -> b) -> [a] -> [b]
map forall {a} {i}. (Num i, Integral a) => a -> i
f [Integer
0::Integer ..]

{- | <http://oeis.org/A005811>

Number of runs in binary expansion of n (n>0); number of 1's in Gray code for n

> take 32 a005811 == [0,1,2,1,2,3,2,1,2,3,4,3,2,3,2,1,2,3,4,3,4,5,4,3,2,3,4,3,2,3,2,1]
-}
a005811 :: Integral n => [n]
a005811 :: forall n. Integral n => [n]
a005811 =
  let f :: [a] -> [a]
f (a
x:[a]
xs) = a
x forall a. a -> [a] -> [a]
: [a] -> [a]
f ([a]
xs forall a. [a] -> [a] -> [a]
++ [a
x forall a. Num a => a -> a -> a
+ a
x forall a. Integral a => a -> a -> a
`mod` a
2, a
x forall a. Num a => a -> a -> a
+ a
1 forall a. Num a => a -> a -> a
- a
x forall a. Integral a => a -> a -> a
`mod` a
2])
      f [a]
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"A005811"
  in n
0 forall a. a -> [a] -> [a]
: forall {a}. Integral a => [a] -> [a]
f [n
1]

{- | <http://oeis.org/A005917>

Rhombic dodecahedral numbers: a(n) = n^4 - (n - 1)^4.

> [1,15,65,175,369,671,1105,1695,2465,3439,4641,6095,7825,9855,12209,14911,17985] `isPrefixOf` a005917
-}
a005917 :: Integral n => [n]
a005917 :: forall n. Integral n => [n]
a005917 =
  let f :: Int -> [a] -> [[a]]
f Int
x [a]
ws = let ([a]
us,[a]
vs) = forall a. Int -> [a] -> ([a], [a])
splitAt Int
x [a]
ws in [a]
us forall a. a -> [a] -> [a]
: Int -> [a] -> [[a]]
f (Int
x forall a. Num a => a -> a -> a
+ Int
2) [a]
vs
  in forall a b. (a -> b) -> [a] -> [b]
map forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall {a}. Int -> [a] -> [[a]]
f Int
1 [n
1, n
3 ..])

{- | <https://oeis.org/A006003>

a(n) = n*(n^2 + 1)/2.

> [0,1,5,15,34,65,111,175,260,369,505,671,870,1105,1379,1695,2056,2465,2925,3439] `isPrefixOf` a006003

> map a006003_n [0 .. 1000] `isPrefixOf` a006003
-}
a006003 :: Integral n => [n]
a006003 :: forall n. Integral n => [n]
a006003 = forall b a. (b -> a -> b) -> b -> [a] -> [b]
scanl forall a. Num a => a -> a -> a
(+) n
0 forall n. Integral n => [n]
a005448

a006003_n :: Integral n => n -> n
a006003_n :: forall n. Integral n => n -> n
a006003_n n
n = n
n forall a. Num a => a -> a -> a
* (n
n forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
2::Int) forall a. Num a => a -> a -> a
+ n
1) forall a. Integral a => a -> a -> a
`div` n
2

{- | <http://oeis.org/A006046>

Total number of odd entries in first n rows of Pascal's triangle: a(0) = 0, a(1) = 1, a(2k) = 3*a(k), a(2k+1) = 2*a(k) + a(k+1).

> [0,1,3,5,9,11,15,19,27,29,33,37,45,49,57,65,81,83,87,91,99,103,111,119,135,139] `isPrefixOf` a006046

> import Sound.SC3.Plot {- hsc3-plot -}
> plot_p1_ln [take 250 a006046]
> let t = log 3 / log 2
> plot_p1_ln [zipWith (/) (map fromIntegral a006046) (map (\n -> n ** t) [0.0,1 .. 200])]
-}
a006046 :: [Int]
a006046 :: [Int]
a006046 = forall a b. (a -> b) -> [a] -> [b]
map (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat) (forall a. [a] -> [[a]]
inits [[Int]]
a047999_tbl)

{- | <http://oeis.org/A006052>

Number of magic squares of order n composed of the numbers from 1 to n^2, counted up to rotations and reflections.

> [1,0,1,880,275305224] == a006052
-}
a006052 :: Integral n => [n]
a006052 :: forall n. Integral n => [n]
a006052 = [n
1,n
0,n
1,n
880,n
275305224]

{- | <http://oeis.org/A006842>

Triangle read by rows: row n gives numerators of Farey series of order n.

> [0,1,0,1,1,0,1,1,2,1,0,1,1,1,2,3,1,0,1,1,1,2,1,3,2,3,4,1,0,1,1,1,1,2,1,3] `isPrefixOf` a006842
> plot_p1_imp [take 200 (a006842 :: [Int])]
> plot_p1_pt [take 10000 (a006842 :: [Int])]
-}
a006842 :: Integral i => [i]
a006842 :: forall n. Integral n => [n]
a006842 = forall a b. (a -> b) -> [a] -> [b]
map forall a. Ratio a -> a
numerator (forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall i. Integral i => i -> [Ratio i]
Math.farey [i
1..])

{- | <http://oeis.org/A006843>

Triangle read by rows: row n gives denominators of Farey series of order n

> [1,1,1,2,1,1,3,2,3,1,1,4,3,2,3,4,1,1,5,4,3,5,2,5,3,4,5,1,1,6,5,4,3,5,2,5] `isPrefixOf` a006843
> plot_p1_imp [take 200 (a006843 :: [Int])]
> plot_p1_pt [take 10000 (a006843 :: [Int])]
-}
a006843 :: Integral i => [i]
a006843 :: forall n. Integral n => [n]
a006843 = forall a b. (a -> b) -> [a] -> [b]
map forall a. Ratio a -> a
denominator (forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall i. Integral i => i -> [Ratio i]
Math.farey [i
1..])

{- | <https://oeis.org/A007318>

Pascal's triangle read by rows

[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1]] `isPrefixOf` a007318_tbl
-}
a007318 :: Integral i => [i]
a007318 :: forall n. Integral n => [n]
a007318 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Integral i => [[i]]
a007318_tbl

a007318_tbl :: Integral i => [[i]]
a007318_tbl :: forall i. Integral i => [[i]]
a007318_tbl =
  let f :: [c] -> [c]
f [c]
r = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
0 forall a. a -> [a] -> [a]
: [c]
r) ([c]
r forall a. [a] -> [a] -> [a]
++ [c
0])
  in forall a. (a -> a) -> a -> [a]
iterate forall {a}. Num a => [a] -> [a]
f [i
1]

{- | <https://oeis.org/A008277>

Triangle of Stirling numbers of the second kind, S2(n,k), n >= 1, 1 <= k <= n.

[1,1,1,1,3,1,1,7,6,1,1,15,25,10,1,1,31,90,65,15,1,1,63,301,350,140,21,1] `isPrefixOf` a008277
-}
a008277 :: (Enum n,Num n) => [n]
a008277 :: forall n. (Enum n, Num n) => [n]
a008277 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall n. (Enum n, Num n) => [[n]]
a008277_tbl

a008277_tbl :: (Enum n,Num n) => [[n]]
a008277_tbl :: forall n. (Enum n, Num n) => [[n]]
a008277_tbl = forall a b. (a -> b) -> [a] -> [b]
map forall a. [a] -> [a]
tail forall n. (Enum n, Num n) => [[n]]
a048993_tbl

{- | <http://oeis.org/A008278>

Triangle of Stirling numbers of 2nd kind, S(n,n-k+1), n >= 1, 1<=k<=n.

[1,1,1,1,3,1,1,6,7,1,1,10,25,15,1,1,15,65,90,31,1,1,21,140,350,301,63,1] `isPrefixOf` a008278
-}
a008278 :: (Enum n,Num n) => [n]
a008278 :: forall n. (Enum n, Num n) => [n]
a008278 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall n. (Enum n, Num n) => [[n]]
a008278_tbl

a008278_tbl :: (Enum n,Num n) => [[n]]
a008278_tbl :: forall n. (Enum n, Num n) => [[n]]
a008278_tbl =
  let f :: [c] -> [c]
f [c]
p =
        let q :: [c]
q = forall a. [a] -> [a]
reverse (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [c
1..] (forall a. [a] -> [a]
reverse [c]
p))
        in forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
0 forall a. a -> [a] -> [a]
: [c]
q) ([c]
p forall a. [a] -> [a] -> [a]
++ [c
0])
  in forall a. (a -> a) -> a -> [a]
iterate forall {c}. (Num c, Enum c) => [c] -> [c]
f [n
1]

{- | <http://oeis.org/A008683>

Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is the product of k different primes; otherwise mu(n) = 0.

> [1,-1,-1,0,-1,1,-1,0,0,1,-1,0,-1,1,1,0,-1,0,-1,0,1,1,-1,0,0,1,0,0,-1,-1,-1,0,1] `isPrefixOf` a008683
-}
a008683 :: Integral n => [n]
a008683 :: forall n. Integral n => [n]
a008683 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a008683_n [n
1..]

a008683_n :: Integral n => n -> n
a008683_n :: forall n. Integral n => n -> n
a008683_n =
  let mu :: [a] -> a
mu [] = a
1
      mu (a
1:[a]
es) = - [a] -> a
mu [a]
es
      mu [a]
_ = a
0
  in forall {a} {a}. (Eq a, Num a, Num a) => [a] -> a
mu forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. [(a, b)] -> ([a], [b])
unzip forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i. Integral i => i -> [(i, Int)]
Prime.prime_factors_m 

{- | <http://oeis.org/A010049>

Second-order Fibonacci numbers.

> [0,1,1,3,5,10,18,33,59,105,185,324,564,977,1685,2895,4957,8462,14406,24465,41455] `isInfixOf` a010049
-}
a010049 :: Num n => [n]
a010049 :: forall n. Num n => [n]
a010049 =
  let c :: [a] -> [a] -> [a]
c [a]
us (a
v:[a]
vs) = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [a]
us (a
1 forall a. a -> [a] -> [a]
: forall a. [a] -> [a]
reverse [a]
us)) forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
c (a
vforall a. a -> [a] -> [a]
:[a]
us) [a]
vs
      c [a]
_ [a]
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"A010049"
  in forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall {a}. Num a => [a] -> [a] -> [a]
c (forall a. Int -> [a] -> ([a], [a])
splitAt Int
1 forall n. Num n => [n]
a000045)

{- | <https://oeis.org/A010060>

Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 0 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtained from A_k by interchanging 0's and 1's.

[0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0] `isPrefixOf` a010060

-}
a010060 :: [Integer]
a010060 :: [Integer]
a010060 =
  let interleave :: [a] -> [a] -> [a]
interleave (a
x:[a]
xs) [a]
ys = a
x forall a. a -> [a] -> [a]
: [a] -> [a] -> [a]
interleave [a]
ys [a]
xs
      interleave [] [a]
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"a010060?"
   in Integer
0 forall a. a -> [a] -> [a]
: forall a. [a] -> [a] -> [a]
interleave (forall a b. (a -> b) -> [a] -> [b]
map (Integer
1 forall a. Num a => a -> a -> a
-) [Integer]
a010060) (forall a. [a] -> [a]
tail [Integer]
a010060)

{- | <https://oeis.org/A014081>

a(n) is the number of occurrences of '11' in binary expansion of n.

> [0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 2, 2, 2, 3, 4, 0, 0, 0, 1, 0, 0, 1, 2] `isPrefixOf` a014081

-}
a014081 :: (Integral i, Bits i) => [i]
a014081 :: forall i. (Integral i, Bits i) => [i]
a014081 = forall a b. (a -> b) -> [a] -> [b]
map (\Int
n -> forall n. Integral n => [n]
a000120 forall a. [a] -> Int -> a
!! (Int
n forall a. Bits a => a -> a -> a
.&. forall a. Integral a => a -> a -> a
div Int
n Int
2)) [Int
0..]

{- | <https://oeis.org/A014577>

The regular paper-folding sequence (or dragon curve sequence).

> [1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1] `isPrefixOf` a014577
-}
a014577 :: Integral i => [i]
a014577 :: forall n. Integral n => [n]
a014577 =
  let f :: t -> t
f t
n = if t
n forall a. Integral a => a -> a -> a
`rem` t
2 forall a. Eq a => a -> a -> Bool
== t
1 then t -> t
f (t
n forall a. Integral a => a -> a -> a
`quot` t
2) else t
1 forall a. Num a => a -> a -> a
- (t
n forall a. Integral a => a -> a -> a
`div` t
2 forall a. Integral a => a -> a -> a
`rem` t
2)
  in forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
f [i
0..]

{- | <http://oeis.org/A016813>

a(n) = 4*n + 1.

> [1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101] `isPrefixOf` a016813
-}
a016813 :: Integral n => [n]
a016813 :: forall n. Integral n => [n]
a016813 = [n
1, n
5 ..]

{- | <http://oeis.org/A017817>

a(n) = a(n-3) + a(n-4), with a(0)=1, a(1)=a(2)=0, a(3)=1

> [1,0,0,1,1,0,1,2,1,1,3,3,2,4,6,5,6,10,11,11,16,21,22,27,37,43,49,64,80,92] `isPrefixOf` a017817
-}
a017817 :: Num n => [n]
a017817 :: forall n. Num n => [n]
a017817 = n
1 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a017817 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a017817)

{- | <http://oeis.org/A020695>

Pisot sequence E(2,3).

> [2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711] `isPrefixOf` a020695
-}
a020695 :: Num n => [n]
a020695 :: forall n. Num n => [n]
a020695 = forall a. Int -> [a] -> [a]
drop Int
3 forall n. Num n => [n]
a000045

{- | <https://oeis.org/A020985>

The Rudin-Shapiro or Golay-Rudin-Shapiro sequence (coefficients of the Shapiro polynomials).		45

> [1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1] `isPrefixOf` a020985
-}
a020985 :: [Integer]
a020985 :: [Integer]
a020985 =
  let f :: [t] -> t -> [t]
f (t
x:[t]
xs) t
w = t
x forall a. a -> [a] -> [a]
: t
xforall a. Num a => a -> a -> a
*t
w forall a. a -> [a] -> [a]
: [t] -> t -> [t]
f [t]
xs (t
0 forall a. Num a => a -> a -> a
- t
w)
      f [] t
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"a020985?"
  in Integer
1 forall a. a -> [a] -> [a]
: Integer
1 forall a. a -> [a] -> [a]
: forall {t}. Num t => [t] -> t -> [t]
f (forall a. [a] -> [a]
tail [Integer]
a020985) (-Integer
1)

{- | <http://oeis.org/A022095>

Fibonacci sequence beginning 1, 5.

> [1,5,6,11,17,28,45,73,118,191,309,500,809,1309,2118,3427,5545,8972,14517,23489] `isPrefixOf` a022095
-}
a022095 :: Num n => [n]
a022095 :: forall n. Num n => [n]
a022095 = n
1 forall a. a -> [a] -> [a]
: n
5 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a022095 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a022095)

{- | <http://oeis.org/A022096>

Fibonacci sequence beginning 1, 6.

> [1,6,7,13,20,33,53,86,139,225,364,589,953,1542,2495,4037,6532,10569,17101,27670] `isPrefixOf` a022096
-}
a022096 :: Num n => [n]
a022096 :: forall n. Num n => [n]
a022096 = n
1 forall a. a -> [a] -> [a]
: n
6 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) forall n. Num n => [n]
a022096 (forall a. [a] -> [a]
tail forall n. Num n => [n]
a022096)

{- | <https://oeis.org/A027750>

Triangle read by rows in which row n lists the divisors of n.

> [1,1,2,1,3,1,2,4,1,5,1,2,3,6,1,7,1,2,4,8,1,3,9,1,2,5,10,1,11,1,2,3,4,6,12,1,13] `isPrefixOf` a027750
-}
a027750 :: Integral n => [n]
a027750 :: forall n. Integral n => [n]
a027750 = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall n. Integral n => n -> [n]
a027750_row [n
1..]

a027750_row :: Integral n => n -> [n]
a027750_row :: forall n. Integral n => n -> [n]
a027750_row n
n = forall a. (a -> Bool) -> [a] -> [a]
filter ((forall a. Eq a => a -> a -> Bool
== n
0) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Integral a => a -> a -> a
mod n
n)) [n
1..n
n]

{- | <http://oeis.org/A027934>

a(0)=0, a(1)=1, a(2)=2; for n > 2, a(n) = 3*a(n-1) - a(n-2) - 2*a(n-3).

> [0,1,2,5,11,24,51,107,222,457,935,1904,3863,7815,15774,31781,63939,128488] `isPrefixOf` a027934
-}
a027934 :: Num n => [n]
a027934 :: forall n. Num n => [n]
a027934 =
  let f :: a -> a -> a -> a
f a
x a
y a
z = a
3 forall a. Num a => a -> a -> a
* a
x forall a. Num a => a -> a -> a
- a
y forall a. Num a => a -> a -> a
- a
2 forall a. Num a => a -> a -> a
* a
z
  in n
0 forall a. a -> [a] -> [a]
: n
1 forall a. a -> [a] -> [a]
: n
2 forall a. a -> [a] -> [a]
: forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith3 forall {a}. Num a => a -> a -> a -> a
f (forall a. Int -> [a] -> [a]
drop Int
2 forall n. Num n => [n]
a027934) (forall a. [a] -> [a]
tail forall n. Num n => [n]
a027934) forall n. Num n => [n]
a027934

{- | <http://oeis.org/A029635>

The (1,2)-Pascal triangle (or Lucas triangle) read by rows.

> [2,1,2,1,3,2,1,4,5,2,1,5,9,7,2,1,6,14,16,9,2,1,7,20,30,25,11,2,1,8,27,50,55,36] `isPrefixOf` a029635
> take 7 a029635_tbl == [[2],[1,2],[1,3,2],[1,4,5,2],[1,5,9,7,2],[1,6,14,16,9,2],[1,7,20,30,25,11,2]]
-}
a029635 :: Num i => [i]
a029635 :: forall n. Num n => [n]
a029635 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Num i => [[i]]
a029635_tbl

a029635_tbl :: Num i => [[i]]
a029635_tbl :: forall i. Num i => [[i]]
a029635_tbl =
  let f :: [c] -> [c]
f [c]
r = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
0 forall a. a -> [a] -> [a]
: [c]
r) ([c]
r forall a. [a] -> [a] -> [a]
++ [c
0])
  in [i
2] forall a. a -> [a] -> [a]
: forall a. (a -> a) -> a -> [a]
iterate forall {a}. Num a => [a] -> [a]
f [i
1,i
2]

{- | <http://oeis.org/A030308>

Triangle T(n,k): Write n in base 2, reverse order of digits, to get the n-th row

> take 9 a030308 == [[0],[1],[0,1],[1,1],[0,0,1],[1,0,1],[0,1,1],[1,1,1],[0,0,0,1]]
-}
a030308 :: (Eq n,Num n) => [[n]]
a030308 :: forall n. (Eq n, Num n) => [[n]]
a030308 =
   let f :: [a] -> [a]
f [a]
l = case [a]
l of
         [] -> [a
1]
         a
0:[a]
b -> a
1 forall a. a -> [a] -> [a]
: [a]
b
         a
1:[a]
b -> a
0 forall a. a -> [a] -> [a]
: [a] -> [a]
f [a]
b
         [a]
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"A030308"
   in forall a. (a -> a) -> a -> [a]
iterate forall {a}. (Num a, Eq a) => [a] -> [a]
f [n
0]

{- | <https://oeis.org/A033622>

Good sequence of increments for Shell sort (best on big values).

[1, 5, 19, 41, 109, 209, 505, 929, 2161, 3905, 8929, 16001, 36289, 64769, 146305, 260609, 587521] `isPrefixOf` a033622
-}
a033622 :: [Integer]
a033622 :: [Integer]
a033622 = forall a b. (a -> b) -> [a] -> [b]
map Integer -> Integer
a033622_n [Integer
0..]

a033622_n :: Integer -> Integer
a033622_n :: Integer -> Integer
a033622_n Integer
n =
  if forall a. Integral a => a -> Bool
even Integer
n
  then Integer
9 forall a. Num a => a -> a -> a
* Integer
2 forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
n forall a. Num a => a -> a -> a
- Integer
9 forall a. Num a => a -> a -> a
* Integer
2 forall a b. (Num a, Integral b) => a -> b -> a
^ ( Integer
n forall a. Integral a => a -> a -> a
`div` Integer
2) forall a. Num a => a -> a -> a
+ Integer
1
  else Integer
8 forall a. Num a => a -> a -> a
* Integer
2 forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
n forall a. Num a => a -> a -> a
- Integer
6 forall a. Num a => a -> a -> a
* Integer
2 forall a b. (Num a, Integral b) => a -> b -> a
^ ((Integer
n forall a. Num a => a -> a -> a
+ Integer
1 )forall a. Integral a => a -> a -> a
`div` Integer
2) forall a. Num a => a -> a -> a
+ Integer
1

{- | <http://oeis.org/A033812>

The Loh-Shu 3 X 3 magic square, lexicographically largest variant when read by columns.
-}
a033812 :: Num n => [n]
a033812 :: forall n. Num n => [n]
a033812 = [n
8, n
1, n
6, n
3, n
5, n
7, n
4, n
9, n
2]

{- | <http://oeis.org/A034968>

Minimal number of factorials that add to n.

> [0,1,1,2,2,3,1,2,2,3,3,4,2,3,3,4,4,5,3,4,4,5,5,6,1,2,2,3,3,4,2,3,3,4,4,5,3,4,4] `isPrefixOf` a034968
-}
a034968 :: Integral n => [n]
a034968 :: forall n. Integral n => [n]
a034968 =
  let f :: t -> t -> t -> t
f t
i t
s t
n = if t
n forall a. Eq a => a -> a -> Bool
== t
0 then t
s else t -> t -> t -> t
f (t
i forall a. Num a => a -> a -> a
+ t
1) (t
s forall a. Num a => a -> a -> a
+ forall a. Integral a => a -> a -> a
rem t
n t
i) (forall a. Integral a => a -> a -> a
quot t
n t
i)
  in forall a b. (a -> b) -> [a] -> [b]
map (forall {t}. Integral t => t -> t -> t -> t
f n
2 n
0) [n
0 ..]

{- | <https://oeis.org/A036562>

a(n) = 4^(n+1) + 3*2^n + 1

[1, 8, 23, 77, 281, 1073, 4193, 16577, 65921, 262913, 1050113, 4197377, 16783361, 67121153] `isPrefixOf` a036562
-}
a036562 :: [Integer]
a036562 :: [Integer]
a036562 = Integer
1 forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map Integer -> Integer
a036562_n [Integer
0..]

a036562_n :: Integer -> Integer
a036562_n :: Integer -> Integer
a036562_n Integer
n = Integer
4forall a b. (Num a, Integral b) => a -> b -> a
^(Integer
nforall a. Num a => a -> a -> a
+Integer
1) forall a. Num a => a -> a -> a
+ Integer
3forall a. Num a => a -> a -> a
*Integer
2forall a b. (Num a, Integral b) => a -> b -> a
^Integer
n forall a. Num a => a -> a -> a
+ Integer
1

{- | <http://oeis.org/A046042>

Number of partitions of n into fourth powers.

> [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3] `isPrefixOf` a046042
-}
a046042 :: Num n => [n]
a046042 :: forall n. Num n => [n]
a046042 =
  let p :: [t] -> t -> a
p [t]
_ t
0 = a
1
      p ks' :: [t]
ks'@(t
k:[t]
ks) t
m = if t
m forall a. Ord a => a -> a -> Bool
< t
k then a
0 else [t] -> t -> a
p [t]
ks' (t
m forall a. Num a => a -> a -> a
- t
k) forall a. Num a => a -> a -> a
+ [t] -> t -> a
p [t]
ks t
m
      p [t]
_ t
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"A046042"
  in forall a b. (a -> b) -> [a] -> [b]
map (forall {t} {a}. (Num t, Num a, Ord t) => [t] -> t -> a
p (forall a. [a] -> [a]
tail forall n. Integral n => [n]
a000583)) [Integer
1::Integer ..]

{- | <http://oeis.org/A047999>

Sierpiński's triangle (or gasket): triangle, read by rows, formed by reading Pascal's triangle mod 2.

> [1,1,1,1,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,0] `isPrefixOf` a047999
-}
a047999 :: [Int]
a047999 :: [Int]
a047999 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Int]]
a047999_tbl

a047999_tbl :: [[Int]]
a047999_tbl :: [[Int]]
a047999_tbl = forall a. (a -> a) -> a -> [a]
iterate (\[Int]
r -> forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Bits a => a -> a -> a
xor (Int
0 forall a. a -> [a] -> [a]
: [Int]
r) ([Int]
r forall a. [a] -> [a] -> [a]
++ [Int
0])) [Int
1]

{- | <https://oeis.org/A048993>

Triangle of Stirling numbers of 2nd kind, S(n,k), n >= 0, 0 <= k <= n.

> [1,0,1,0,1,1,0,1,3,1,0,1,7,6,1,0,1,15,25,10,1,0,1,31,90,65,15,1] `isPrefixOf` a048993
-}
a048993 :: (Enum n,Num n) => [n]
a048993 :: forall n. (Enum n, Num n) => [n]
a048993 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall n. (Enum n, Num n) => [[n]]
a048993_tbl

a048993_tbl :: (Enum n,Num n) => [[n]]
a048993_tbl :: forall n. (Enum n, Num n) => [[n]]
a048993_tbl = forall a. (a -> a) -> a -> [a]
iterate (\[n]
row -> n
0 forall a. a -> [a] -> [a]
: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) [n]
row (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(*) [n
1..] (forall a. [a] -> [a]
tail [n]
row)) forall a. [a] -> [a] -> [a]
++ [n
1]) [n
1]

{- | <http://oeis.org/A049455>

Triangle read by rows, numerator of fractions of a variant of the Farey series.

> [0,1,0,1,1,0,1,1,2,1,0,1,1,2,1,3,2,3,1,0,1,1,2,1,3,2,3,1,4,3,5,2,5,3,4,1,0] `isPrefixOf` a049455
> plot_p1_imp [take 200 (a049455 :: [Int])]
> plot_p1_pt [take 10000 (a049455 :: [Int])]
-}
a049455 :: Integral n => [n]
a049455 :: forall n. Integral n => [n]
a049455 = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall n. Num n => [[(n, n)]]
Math.stern_brocot_tree_lhs)

{- | <http://oeis.org/A049456>

Triangle read by rows, denominator of fractions of a variant of the Farey series.

[1,1,1,2,1,1,3,2,3,1,1,4,3,5,2,5,3,4,1,1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5,1,1,6,5,9] `isPrefixOf` a049456
> plot_p1_imp [take 200 (a049456 :: [Int])]
> plot_p1_pt [take 10000 (a049456 :: [Int])]
-}
a049456 :: Integral n => [n]
a049456 :: forall n. Integral n => [n]
a049456 = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall n. Num n => [[(n, n)]]
Math.stern_brocot_tree_lhs)

{- | <http://oeis.org/A053121>

Catalan triangle (with 0's) read by rows.

> [1,0,1,1,0,1,0,2,0,1,2,0,3,0,1,0,5,0,4,0,1,5,0,9,0,5,0,1,0,14,0,14,0,6,0,1,14,0] `isPrefixOf` a053121
> take 7 a053121_tbl == [[1],[0,1],[1,0,1],[0,2,0,1],[2,0,3,0,1],[0,5,0,4,0,1],[5,0,9,0,5,0,1]]
-}
a053121 :: Num n => [n]
a053121 :: forall n. Num n => [n]
a053121 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Num i => [[i]]
a053121_tbl

a053121_tbl :: Num n => [[n]]
a053121_tbl :: forall i. Num i => [[i]]
a053121_tbl = forall a. (a -> a) -> a -> [a]
iterate (\[n]
row -> forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (n
0 forall a. a -> [a] -> [a]
: [n]
row) (forall a. [a] -> [a]
tail [n]
row forall a. [a] -> [a] -> [a]
++ [n
0, n
0])) [n
1]

{- | <http://oeis.org/A058265>

Decimal expansion of the tribonacci constant t, the real root of x^3 - x^2 - x - 1.

> [1,8,3,9,2,8,6,7,5,5,2,1,4,1,6,1,1,3,2,5,5,1,8,5,2,5,6,4,6,5,3,2,8,6,6,0,0,4,2] `isPrefixOf` a058265

> a058265_k :: Data.Number.Fixed.Fixed Data.Number.Fixed.Prec500 {- numbers -}
-}
a058265 :: Num n => [n]
a058265 :: forall n. Num n => [n]
a058265 = forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
digitToInt) [Char]
"183928675521416113255185256465328660042417874609759224677875863940420322208196642573843541942830701414197982685924097416417845074650743694383154582049951379624965553964461366612154027797267811894104121160922328215595607181671218236598665227337853781569698925211739579141322872106187898408525495693114534913498534595761750359652213238142472727224173581877000697905510254904496571074252654772281100659893755563630933305282623575385197199429914530082546639774729005870059744813919316728258488396263329709" forall a. [a] -> [a] -> [a]
++ forall a. HasCallStack => [Char] -> a
error [Char]
"A058265"

-- | A058265 as 'Floating' calculation, see "Data.Number.Fixed".
a058265_k :: Floating n => n
a058265_k :: forall n. Floating n => n
a058265_k = (n
1forall a. Fractional a => a -> a -> a
/n
3) forall a. Num a => a -> a -> a
* (n
1 forall a. Num a => a -> a -> a
+ (n
19 forall a. Num a => a -> a -> a
+ n
3 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt n
33) forall a. Floating a => a -> a -> a
** (n
1forall a. Fractional a => a -> a -> a
/n
3) forall a. Num a => a -> a -> a
+ (n
19 forall a. Num a => a -> a -> a
- n
3 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt n
33)  forall a. Floating a => a -> a -> a
** (n
1forall a. Fractional a => a -> a -> a
/n
3))

{- | <http://oeis.org/A060588>

If the final two digits of n written in base 3 are the same then this digit, otherwise mod 3-sum of these two digits.

> [0,2,1,2,1,0,1,0,2,0,2,1,2,1,0,1,0,2,0,2,1,2,1,0,1,0,2,0,2,1,2,1,0,1,0,2,0,2,1] `isPrefixOf` a060588a
-}
a060588a :: Integral n => [n]
a060588a :: forall n. Integral n => [n]
a060588a = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a060588a_n [n
0..]

a060588a_n :: Integral n => n -> n
a060588a_n :: forall n. Integral n => n -> n
a060588a_n n
n = (-n
n forall a. Num a => a -> a -> a
- forall a b. (RealFrac a, Integral b) => a -> b
floor (forall a b. (Integral a, Num b) => a -> b
fromIntegral n
n forall a. Fractional a => a -> a -> a
/ (Double
3::Double))) forall a. Integral a => a -> a -> a
`mod` n
3

{- | <http://oeis.org/A061654>

a(n) = (3*16^n + 2)/5

> [1,10,154,2458,39322,629146,10066330,161061274,2576980378,41231686042] `isPrefixOf` a061654
-}
a061654 :: Integral n => [n]
a061654 :: forall n. Integral n => [n]
a061654 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a061654_n [n
0 ..]

a061654_n :: Integral n => n -> n
a061654_n :: forall n. Integral n => n -> n
a061654_n n
n = (n
3 forall a. Num a => a -> a -> a
* n
16forall a b. (Num a, Integral b) => a -> b -> a
^n
n forall a. Num a => a -> a -> a
+ n
2) forall a. Integral a => a -> a -> a
`div` n
5

{- | <http://oeis.org/A071996>

a(1) = 0, a(2) = 1, a(n) = a(floor(n/3)) + a(n - floor(n/3)).

> [0,1,1,1,1,2,2,3,3,3,4,4,4,4,4,5,5,6,6,6,6,6,7,8,8,9,9,9,9,9,9,9,10,11,12,12,12] `isPrefixOf` a071996

> plot_p1_ln [take 50 a000201 :: [Int]]
> plot_p1_imp [map length (take 250 (group a071996))]
-}
a071996 :: Integral n => [n]
a071996 :: forall n. Integral n => [n]
a071996 =
  let f :: t -> a
f t
n =
        case t
n of
          t
0 -> forall a. HasCallStack => [Char] -> a
error [Char]
"A071996"
          t
1 -> a
0
          t
2 -> a
1
          t
_ -> let m :: t
m = forall a b. (RealFrac a, Integral b) => a -> b
floor (forall a b. (Integral a, Num b) => a -> b
fromIntegral t
n forall a. Fractional a => a -> a -> a
/ (Double
3::Double)) in t -> a
f t
m forall a. Num a => a -> a -> a
+ t -> a
f (t
n forall a. Num a => a -> a -> a
- t
m)
  in forall a b. (a -> b) -> [a] -> [b]
map forall {a} {i}. (Num i, Integral a) => a -> i
f [Int
1::Int ..]

{- | <http://oeis.org/A073334>

The "rhythmic infinity system" of Danish composer Per Nørgård

> take 24 a073334 == [3,5,8,5,8,13,8,5,8,13,21,13,8,13,8,5,8,13,21,13,21,34,21,13]
> plot_p1_imp [take 200 (a073334 :: [Int])]
-}
a073334 :: Num n => [n]
a073334 :: forall n. Num n => [n]
a073334 =
  let f :: Int -> a
f Int
n = forall n. Num n => [n]
a000045 forall a. [a] -> Int -> a
!! ((forall n. Integral n => [n]
a005811 forall a. [a] -> Int -> a
!! Int
n) forall a. Num a => a -> a -> a
+ Int
4)
  in n
3 forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => Int -> a
f [Int
1..]

{- | <https://oeis.org/A080843>

Tribonacci word: limit S(infinity), where S(0) = 0, S(1) = 0,1, S(2) = 0,1,0,2 and for n >= 0, S(n+3) = S(n+2) S(n+1) S(n).

> [0,1,0,2,0,1,0,0,1,0,2,0,1,0,1,0,2,0,1,0,0,1,0,2,0,1,0,2,0,1,0,0,1,0,2,0,1,0,1] `isPrefixOf` a080843
-}
a080843 :: Integral n => [n]
a080843 :: forall n. Integral n => [n]
a080843 =
  let rw :: a -> [a]
rw a
n = case a
n of {a
0 -> [a
0,a
1];a
1 -> [a
0,a
2];a
2 -> [a
0];a
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"A080843"}
      unf :: [[a]] -> [a]
unf = let f :: Int -> [[a]] -> [a]
f Int
n [[a]]
l = case [[a]]
l of {[] -> forall a. HasCallStack => [Char] -> a
error [Char]
"A080843";[a]
x:[[a]]
xs -> forall a. Int -> [a] -> [a]
drop Int
n [a]
x forall a. [a] -> [a] -> [a]
++ Int -> [[a]] -> [a]
f (forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
x) [[a]]
xs} in forall {a}. Int -> [[a]] -> [a]
f Int
0
  in forall {a}. [[a]] -> [a]
unf (forall a. (a -> a) -> a -> [a]
iterate (forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {a} {a}. (Eq a, Num a, Num a) => a -> [a]
rw) [n
0])

{- | <http://oeis.org/A080992>

Entries in Durer's magic square.

> [16,3,2,13,5,10,11,8,9,6,7,12,4,15,14,1] == a080992
-}
a080992 :: Num n => [n]
a080992 :: forall n. Num n => [n]
a080992 =
  [n
16,n
03,n
02,n
13
  ,n
05,n
10,n
11,n
08
  ,n
09,n
06,n
07,n
12
  ,n
04,n
15,n
14,n
01]

{- | <http://oeis.org/A083866>

Positions of zeros in Per Nørgård's infinity sequence (A004718).

> take 24 a083866 == [0,5,10,17,20,27,34,40,45,54,65,68,75,80,85,90,99,105,108,119,130,136,141,150]
-}
a083866 :: (Enum n,Num n) => [n]
a083866 :: forall n. (Enum n, Num n) => [n]
a083866 = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd (forall a. (a -> Bool) -> [a] -> [a]
filter ((forall a. Eq a => a -> a -> Bool
== (Int
0::Int)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) (forall a b. [a] -> [b] -> [(a, b)]
zip forall n. Num n => [n]
a004718 [n
0..]))

{- | <http://oeis.org/A095660>

Pascal (1,3) triangle.

> [3,1,3,1,4,3,1,5,7,3,1,6,12,10,3,1,7,18,22,13,3,1,8,25,40,35,16,3,1,9,33,65,75] `isPrefixOf` a095660
> take 6 a095660_tbl == [[3],[1,3],[1,4,3],[1,5,7,3],[1,6,12,10,3],[1,7,18,22,13,3]]
-}
a095660 :: Num i => [i]
a095660 :: forall n. Num n => [n]
a095660 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Num i => [[i]]
a095660_tbl

a095660_tbl :: Num i => [[i]]
a095660_tbl :: forall i. Num i => [[i]]
a095660_tbl =
  let f :: [c] -> [c]
f [c]
r = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
0 forall a. a -> [a] -> [a]
: [c]
r) ([c]
r forall a. [a] -> [a] -> [a]
++ [c
0])
  in [i
3] forall a. a -> [a] -> [a]
: forall a. (a -> a) -> a -> [a]
iterate forall {a}. Num a => [a] -> [a]
f [i
1,i
3]

{- | <http://oeis.org/A095666>

Pascal (1,4) triangle.

> [4,1,4,1,5,4,1,6,9,4,1,7,15,13,4,1,8,22,28,17,4,1,9,30,50,45,21,4,1,10,39,80,95] `isPrefixOf` a095666
> take 6 a095666_tbl == [[4],[1,4],[1,5,4],[1,6,9,4],[1,7,15,13,4],[1,8,22,28,17,4]]
-}
a095666 :: Num i => [i]
a095666 :: forall n. Num n => [n]
a095666 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Num i => [[i]]
a095666_tbl

a095666_tbl :: Num i => [[i]]
a095666_tbl :: forall i. Num i => [[i]]
a095666_tbl =
  let f :: [c] -> [c]
f [c]
r = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
0 forall a. a -> [a] -> [a]
: [c]
r) ([c]
r forall a. [a] -> [a] -> [a]
++ [c
0])
  in [i
4] forall a. a -> [a] -> [a]
: forall a. (a -> a) -> a -> [a]
iterate forall {a}. Num a => [a] -> [a]
f [i
1,i
4]

{- | <http://oeis.org/A096940>

Pascal (1,5) triangle.

> [5,1,5,1,6,5,1,7,11,5,1,8,18,16,5,1,9,26,34,21,5,1,10,35,60,55,26,5,1,11,45,95] `isPrefixOf` a096940
> take 6 a096940_tbl == [[5],[1,5],[1,6,5],[1,7,11,5],[1,8,18,16,5],[1,9,26,34,21,5]]
-}
a096940 :: Num i => [i]
a096940 :: forall n. Num n => [n]
a096940 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Num i => [[i]]
a096940_tbl

a096940_tbl :: Num i => [[i]]
a096940_tbl :: forall i. Num i => [[i]]
a096940_tbl =
  let f :: [c] -> [c]
f [c]
r = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
0 forall a. a -> [a] -> [a]
: [c]
r) ([c]
r forall a. [a] -> [a] -> [a]
++ [c
0])
  in [i
5] forall a. a -> [a] -> [a]
: forall a. (a -> a) -> a -> [a]
iterate forall {a}. Num a => [a] -> [a]
f [i
1,i
5]

{- | <http://oeis.org/A105809>

A Fibonacci-Pascal matrix.

> [1,1,1,2,2,1,3,4,3,1,5,7,7,4,1,8,12,14,11,5,1,13,20,26,25,16,6,1,21,33,46,51,41] `isPrefixOf` a105809
-}
a105809 :: Num n => [n]
a105809 :: forall n. Num n => [n]
a105809 = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall i. Num i => [[i]]
a105809_tbl

a105809_tbl :: Num n => [[n]]
a105809_tbl :: forall i. Num i => [[i]]
a105809_tbl =
  let f :: ([c], [c]) -> ([c], [c])
f (c
u:[c]
_, [c]
vs) = ([c]
vs, forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall a. Num a => a -> a -> a
(+) (c
u forall a. a -> [a] -> [a]
: [c]
vs) ([c]
vs forall a. [a] -> [a] -> [a]
++ [c
0]))
      f ([c], [c])
_ = forall a. HasCallStack => [Char] -> a
error [Char]
"A105809"
  in forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst (forall a. (a -> a) -> a -> [a]
iterate forall {c}. Num c => ([c], [c]) -> ([c], [c])
f ([n
1], [n
1, n
1]))

{- | <http://oeis.org/A124010>

Triangle in which first row is 0, n-th row (n>1) lists the (ordered)
prime signature of n, that is, the exponents of distinct prime factors
in factorization of n.

> [0,1,1,2,1,1,1,1,3,2,1,1,1,2,1,1,1,1,1,1,4,1,1,2,1,2,1,1,1,1,1,1,3,1,2,1,1,3,2,1,1,1,1,1,1,5,1] `isPrefixOf` a124010
-}
a124010 :: Integral n => [n]
a124010 :: forall n. Integral n => [n]
a124010 = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall n. Integral n => n -> [n]
a124010_row [n
1..]

a124010_row :: Integral n => n -> [n]
a124010_row :: forall n. Integral n => n -> [n]
a124010_row n
n =
  let f :: a -> [a] -> [a]
f a
u [a]
w =
        case (a
u, [a]
w) of
          (a
1, [a]
_) -> []
          (a
_, a
p:[a]
ps) ->
            let h :: a -> a -> [a]
h a
v a
e =
                  let (a
v', a
m) = forall a. Integral a => a -> a -> (a, a)
divMod a
v a
p
                  in if a
m forall a. Eq a => a -> a -> Bool
== a
0
                     then a -> a -> [a]
h a
v' (a
e forall a. Num a => a -> a -> a
+ a
1)
                     else if a
e forall a. Ord a => a -> a -> Bool
> a
0
                          then a
e forall a. a -> [a] -> [a]
: a -> [a] -> [a]
f a
v [a]
ps
                          else a -> [a] -> [a]
f a
v [a]
ps
            in a -> a -> [a]
h a
u a
0
          (a, [a])
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"a124010"
  in if n
n forall a. Eq a => a -> a -> Bool
== n
1 then [n
0] else forall {a} {a}. (Num a, Ord a, Integral a) => a -> [a] -> [a]
f n
n forall n. Integral n => [n]
a000040

{- | <https://oeis.org/A124472>

Benjamin Franklin's 16 X 16 magic square read by rows.

> [200,217,232,249,8,25,40,57,72,89,104,121,136,153,168,185,58,39,26,7,250,231] `isPrefixOf` a124472
-}
a124472 :: Num n => [n]
a124472 :: forall n. Num n => [n]
a124472 =
  forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
  [[n
200,n
217,n
232,n
249,n
8,n
25,n
40,n
57,n
72,n
89,n
104,n
121,n
136,n
153,n
168,n
185]
  ,[n
58,n
39,n
26,n
7,n
250,n
231,n
218,n
199,n
186,n
167,n
154,n
135,n
122,n
103,n
90,n
71]
  ,[n
198,n
219,n
230,n
251,n
6,n
27,n
38,n
59,n
70,n
91,n
102,n
123,n
134,n
155,n
166,n
187]
  ,[n
60,n
37,n
28,n
5,n
252,n
229,n
220,n
197,n
188,n
165,n
156,n
133,n
124,n
101,n
92,n
69]
  ,[n
201,n
216,n
233,n
248,n
9,n
24,n
41,n
56,n
73,n
88,n
105,n
120,n
137,n
152,n
169,n
184]
  ,[n
55,n
42,n
23,n
10,n
247,n
234,n
215,n
202,n
183,n
170,n
151,n
138,n
119,n
106,n
87,n
74]
  ,[n
203,n
214,n
235,n
246,n
11,n
22,n
43,n
54,n
75,n
86,n
107,n
118,n
139,n
150,n
171,n
182]
  ,[n
53,n
44,n
21,n
12,n
245,n
236,n
213,n
204,n
181,n
172,n
149,n
140,n
117,n
108,n
85,n
76]
  ,[n
205,n
212,n
237,n
244,n
13,n
20,n
45,n
52,n
77,n
84,n
109,n
116,n
141,n
148,n
173,n
180]
  ,[n
51,n
46,n
19,n
14,n
243,n
238,n
211,n
206,n
179,n
174,n
147,n
142,n
115,n
110,n
83,n
78]
  ,[n
207,n
210,n
239,n
242,n
15,n
18,n
47,n
50,n
79,n
82,n
111,n
114,n
143,n
146,n
175,n
178]
  ,[n
49,n
48,n
17,n
16,n
241,n
240,n
209,n
208,n
177,n
176,n
145,n
144,n
113,n
112,n
81,n
80]
  ,[n
196,n
221,n
228,n
253,n
4,n
29,n
36,n
61,n
68,n
93,n
100,n
125,n
132,n
157,n
164,n
189]
  ,[n
62,n
35,n
30,n
3,n
254,n
227,n
222,n
195,n
190,n
163,n
158,n
131,n
126,n
99,n
94,n
67]
  ,[n
194,n
223,n
226,n
255,n
2,n
31,n
34,n
63,n
66,n
95,n
98,n
127,n
130,n
159,n
162,n
191]
  ,[n
64,n
33,n
32,n
1,n
256,n
225,n
224,n
193,n
192,n
161,n
160,n
129,n
128,n
97,n
96,n
65]]

{- | <http://oeis.org/A125519>

A 4 x 4 permutation-free magic square.
-}
a125519 :: Num n => [n]
a125519 :: forall n. Num n => [n]
a125519 = [n
831,n
326,n
267,n
574,n
584,n
257,n
316,n
841,n
158,n
683,n
742,n
415,n
425,n
732,n
673,n
168]

{- | <http://oeis.org/A126275>

Moment of inertia of all magic squares of order n.

> [5,60,340,1300,3885,9800,21840,44280,83325,147620,248820,402220,627445,949200] `isPrefixOf` a126275
-}
a126275 :: Integral n => [n]
a126275 :: forall n. Integral n => [n]
a126275 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a126275_n [n
2..]

a126275_n :: Integral n => n -> n
a126275_n :: forall n. Integral n => n -> n
a126275_n n
n = (n
n forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
2::Int) forall a. Num a => a -> a -> a
* (n
n forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
4::Int) forall a. Num a => a -> a -> a
- n
1)) forall a. Integral a => a -> a -> a
`div` n
12

{- | <http://oeis.org/A126276>

Moment of inertia of all magic cubes of order n.

> [18,504,5200,31500,136710,471968,1378944,3547800,8258250,17728920,35603568] `isPrefixOf` a126276
-}
a126276 :: Integral n => [n]
a126276 :: forall n. Integral n => [n]
a126276 = forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> n
a126276_n [n
2..]

a126276_n :: Integral n => n -> n
a126276_n :: forall n. Integral n => n -> n
a126276_n n
n = (n
n forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
3::Int) forall a. Num a => a -> a -> a
* (n
n forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
3::Int) forall a. Num a => a -> a -> a
+ n
1) forall a. Num a => a -> a -> a
* (n
n forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
2::Int) forall a. Num a => a -> a -> a
- n
1)) forall a. Integral a => a -> a -> a
`div` n
12

{- | <http://oeis.org/A126651>

A 7 x 7 magic square.
-}
a126651 :: Num n => [n]
a126651 :: forall n. Num n => [n]
a126651 =
  [n
71,  n
1, n
51, n
32, n
50,  n
2, n
80
  ,n
21, n
41, n
61, n
56, n
26, n
13, n
69
  ,n
31, n
81, n
11, n
20, n
62, n
65, n
17
  ,n
34, n
40, n
60, n
43, n
28, n
64, n
18
  ,n
48, n
42, n
22, n
54, n
39, n
75,  n
7
  ,n
33, n
53, n
15, n
68, n
16, n
44, n
58
  ,n
49, n
29, n
67, n
14, n
66, n
24, n
38]

{- | <http://oeis.org/A126652>

A 3 X 3 magic square with magic sum 75: the Loh-Shu square A033812 multiplied by 5.

> a126652 == map (* 5) a033812
-}
a126652 :: Num n => [n]
a126652 :: forall n. Num n => [n]
a126652 = [n
40, n
5, n
30, n
15, n
25, n
35, n
20, n
45, n
10]

{- | <http://oeis.org/A126653>

A 3 X 3 magic square with magic sum 45: the Loh-Shu square A033812 multiplied by 3.

> a126653 == map (* 3) a033812
-}
a126653 :: Num n => [n]
a126653 :: forall n. Num n => [n]
a126653 = [n
24, n
3, n
18, n
9, n
15, n
21, n
12, n
27, n
6]

{- | <http://oeis.org/A126654>

A 3 x 3 magic square.
-}
a126654 :: Num n => [n]
a126654 :: forall n. Num n => [n]
a126654 = [n
32, n
4, n
24, n
12, n
20, n
28, n
16, n
36, n
8]

{- | <http://oeis.org/A126709>

The Loh-Shu 3 x 3 magic square, variant 2.

Loh-Shu magic square, attributed to the legendary Fu Xi (Fuh-Hi).
-}
a126709 :: Num n => [n]
a126709 :: forall n. Num n => [n]
a126709 =
  [n
4,n
9,n
2
  ,n
3,n
5,n
7
  ,n
8,n
1,n
6]

{- | <http://oeis.org/A126710>

Jaina inscription of the twelfth or thirteenth century, Khajuraho, India.
-}
a126710 :: Num n => [n]
a126710 :: forall n. Num n => [n]
a126710 =
  [ n
7,n
12, n
1,n
14
  , n
2,n
13, n
8,n
11
  ,n
16, n
3,n
10, n
5
  , n
9, n
6,n
15, n
4]

{- | <http://oeis.org/A126976>

A 6 x 6 magic square read by rows.

Agrippa (Magic Square of the Sun)
-}
a126976 :: Num n => [n]
a126976 :: forall n. Num n => [n]
a126976 =
  [n
06,n
32,n
03,n
34,n
35,n
01
  ,n
07,n
11,n
27,n
28,n
08,n
30
  ,n
19,n
14,n
16,n
15,n
23,n
24
  ,n
18,n
20,n
22,n
21,n
17,n
13
  ,n
25,n
29,n
10,n
09,n
26,n
12
  ,n
36,n
05,n
33,n
04,n
02,n
31]

{- | <https://oeis.org/A212804>

Expansion of (1 - x)/(1 - x - x^2).

[1,0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946] `isPrefixOf` a212804
-}
a212804 :: Integral n => [n]
a212804 :: forall n. Integral n => [n]
a212804 = n
1 forall a. a -> [a] -> [a]
: forall n. Num n => [n]
a000045

{- | <https://oeis.org/A245553>

A Rauzy fractal sequence: trajectory of 1 under morphism 1 -> 2,3; 2 -> 3; 3 -> 1.

> [1,2,3,2,3,3,1,2,3,3,1,3,1,1,2,3,2,3,3,1,3,1,1,2,3,3,1,1,2,3,1,2,3,2,3,3,1,2,3] `isPrefixOf` a245553
-}
a245553 :: Integral n => [n]
a245553 :: forall n. Integral n => [n]
a245553 =
  let rw :: a -> [a]
rw a
n = case a
n of {a
1 -> [a
2,a
3];a
2 -> [a
3];a
3 -> [a
1];a
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"A245553"}
      jn :: [a] -> [a]
jn [a]
x = [a]
x forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {a} {a}. (Eq a, Num a, Num a) => a -> [a]
rw [a]
x
      unf :: [[a]] -> [a]
unf = let f :: Int -> [[a]] -> [a]
f Int
n [[a]]
l = case [[a]]
l of {[] -> forall a. HasCallStack => [Char] -> a
error [Char]
"A245553";[a]
x:[[a]]
xs -> forall a. Int -> [a] -> [a]
drop Int
n [a]
x forall a. [a] -> [a] -> [a]
++ Int -> [[a]] -> [a]
f (forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
x) [[a]]
xs} in forall {a}. Int -> [[a]] -> [a]
f Int
0
  in forall {a}. [[a]] -> [a]
unf (forall a. (a -> a) -> a -> [a]
iterate forall {a}. (Eq a, Num a) => [a] -> [a]
jn [n
1])

{- | <http://oeis.org/A255723>

Another variant of Per Nørgård's "infinity sequence"

> take 24 a255723 == [0,-2,-1,2,-2,-4,1,0,-1,-3,0,1,2,0,-3,4,-2,-4,1,0,-4,-6,3,-2]
> plot_p1_imp [take 400 (a255723 :: [Int])]
-}
a255723 :: Num n => [n]
a255723 :: forall n. Num n => [n]
a255723 = n
0 forall a. a -> [a] -> [a]
: forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. [[a]] -> [[a]]
transpose [forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
subtract n
2) forall n. Num n => [n]
a255723
                                ,forall a b. (a -> b) -> [a] -> [b]
map (-n
1 forall a. Num a => a -> a -> a
-) forall n. Num n => [n]
a255723
                                ,forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
+ n
2) forall n. Num n => [n]
a255723
                                ,forall a. [a] -> [a]
tail forall n. Num n => [n]
a255723])

{- | <http://oeis.org/A256184>

First of two variations by Per Nørgård of his "infinity sequence"

> take 24 a256184 == [0,-2,-1,2,-4,-3,1,-3,-2,-2,0,1,4,-6,-5,3,-5,-4,-1,-1,0,3,-5,-4]
-}
a256184 :: Num n => [n]
a256184 :: forall n. Num n => [n]
a256184 = n
0 forall a. a -> [a] -> [a]
: forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. [[a]] -> [[a]]
transpose [forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
subtract n
2) forall n. Num n => [n]
a256184
                                ,forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
subtract n
1) forall n. Num n => [n]
a256184
                                ,forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => a -> a
negate (forall a. [a] -> [a]
tail forall n. Num n => [n]
a256184)])

{- | <http://oeis.org/A256185>

Second of two variations by Per Nørgård of his "infinity sequence"

> take 24 a256185 == [0,-3,-2,3,-6,1,2,-5,0,-3,0,-5,6,-9,4,-1,-2,-3,-2,-1,-4,5,-8,3]
-}
a256185 :: Num n => [n]
a256185 :: forall n. Num n => [n]
a256185 = n
0 forall a. a -> [a] -> [a]
: forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. [[a]] -> [[a]]
transpose [forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
subtract n
3) forall n. Num n => [n]
a256185
                                ,forall a b. (a -> b) -> [a] -> [b]
map (-n
2 forall a. Num a => a -> a -> a
-) forall n. Num n => [n]
a256185
                                ,forall a b. (a -> b) -> [a] -> [b]
map forall {a}. Num a => a -> a
negate (forall a. [a] -> [a]
tail forall n. Num n => [n]
a256185)])

{- | <http://oeis.org/A270876>

Number of magic tori of order n composed of the numbers from 1 to n^2.

> [1,0,1,255,251449712] == a270876
-}
a270876 :: Integral n => [n]
a270876 :: forall n. Integral n => [n]
a270876 = [n
1,n
0,n
1,n
255,n
251449712]

{- | <http://oeis.org/A320872>

For all possible 3 X 3 magic squares made of primes, in order of increasing magic sum, list the lexicographically smallest representative of each equivalence class (modulo symmetries of the square), as a row of the 9 elements (3 rows of 3 elements each).
-}
a320872 :: Num n => [n]
a320872 :: forall n. Num n => [n]
a320872 =
  [n
17, n
89,  n
71,  n
113,  n
59,  n
5, n
47, n
29, n
101
  ,n
41, n
89,  n
83,  n
113,  n
71, n
29, n
59, n
53, n
101
  ,n
37, n
79,  n
103, n
139,  n
73,  n
7, n
43, n
67, n
109
  ,n
29, n
131, n
107, n
167,  n
89, n
11, n
71, n
47, n
149
  ,n
43, n
127, n
139, n
199, n
103,  n
7, n
67, n
79, n
163
  ,n
37, n
151, n
139, n
211, n
109,  n
7, n
79, n
67, n
181
  ,n
43, n
181, n
157, n
241, n
127, n
13, n
97, n
73, n
211]