Bell numbers: Difference between revisions

m
added whitespace and Oxford comma.
(→‎{{header|jq}}: Using the C-based implementation of jq)
m (added whitespace and Oxford comma.)
Line 1:
{{task}}
 
[[wp:Bell number|Bell or exponential numbers]] are enumerations of the number of different ways to partition a set that has exactly '''n''' elements. Each element of the sequence&nbsp; '''B<sub>n</sub>''' is the number of partitions of a set of size '''n''' where order of the&nbsp; elements and order of the partitions are non-significant. E.G.: '''{a b}''' is the same as '''{b a}''' and '''{a} {b}''' is the same as '''{b} {a}'''.
 
Each element of the sequence &nbsp; '''B<sub>n</sub>''' &nbsp; is the number of partitions of a set of size &nbsp; '''n''' &nbsp; where order of the elements and order of the partitions are non-significant.
 
;So:
 
;E.G.:
:'''B<sub>0</sub> = 1''' trivially. There is only one way to partition a set with zero elements. '''{ }'''
'''{a b}''' &nbsp; is the same as &nbsp; '''{b a}''', &nbsp; and &nbsp; &nbsp; '''{a} {b}''' &nbsp; is the same as &nbsp; '''{b} {a}'''.
 
:'''B<sub>1</sub> = 1''' There is only one way to partition a set with one element. '''{a}'''
 
;So:
:'''B<sub>2</sub> = 2''' Two elements may be partitioned in two ways. '''{a} {b}, {a b}'''
:&nbsp; '''B<sub>0</sub> = 1''' &nbsp; trivially. &nbsp; There is only one way to partition a set with zero elements.: &nbsp; '''{ }'''
:&nbsp; '''B<sub>1</sub> = 1''' &nbsp; There is only one way to partition a set with one element.: &nbsp; &nbsp; '''{a}'''
:&nbsp; '''B<sub>2</sub> = 2''' &nbsp; Two elements may be partitioned in two ways.: &nbsp; &nbsp; '''{a} {b}, &nbsp; &nbsp; {a b}'''
:&nbsp; '''B<sub>3</sub> = 5''' &nbsp; Three elements may be partitioned in five ways: &nbsp; &nbsp; '''{a} {b} {c}, &nbsp; &nbsp; {a b} {c}, &nbsp; &nbsp; {a} {b c}, &nbsp; &nbsp; {a c} {b}, &nbsp; &nbsp; {a b c}'''
: &nbsp; and so on.
 
:'''B<sub>3</sub> = 5''' Three elements may be partitioned in five ways '''{a} {b} {c}, {a b} {c}, {a} {b c}, {a c} {b}, {a b c}'''
 
A simple way to find the Bell numbers is construct a '''[[wp:Bell_triangle|Bell triangle]]''', &nbsp; also known as an '''Aitken's array''' &nbsp; or &nbsp; '''Peirce triangle''', &nbsp; and read off the numbers in the first column of each row. There are other generating algorithms though, and you are free to choose the best / most appropriate for your case.
: and so on.
 
There are other generating algorithms though, &nbsp; and you are free to choose the best/most appropriate for your case.
 
A simple way to find the Bell numbers is construct a '''[[wp:Bell_triangle|Bell triangle]]''', also known as an '''Aitken's array''' or '''Peirce triangle''', and read off the numbers in the first column of each row. There are other generating algorithms though, and you are free to choose the best / most appropriate for your case.
 
 
;Task:
Write a routine (function, generator, whatever) to generate the Bell number sequence and call the routine to show here, &nbsp; on this page at least the '''first 15''' and (if your language supports big Integers) &nbsp; '''50th''' &nbsp; elements of the sequence.
 
If you ''do'' use the Bell triangle method to generate the numbers, &nbsp; also show the '''first ten rows''' of the Bell triangle.
Write a routine (function, generator, whatever) to generate the Bell number sequence and call the routine to show here, on this page at least the '''first 15''' and (if your language supports big Integers) '''50th''' elements of the sequence.
 
If you ''do'' use the Bell triangle method to generate the numbers, also show the '''first ten rows''' of the Bell triangle.
 
 
;See also:
:* &nbsp; '''[[oeis:A000110|OEIS:A000110 Bell or exponential numbers]]'''
 
:* &nbsp; '''[[oeis:A000110A011971|OEIS:A000110A011971 Bell or exponentialAitken's numbersarray]]'''
<br><br>
:* '''[[oeis:A011971|OEIS:A011971 Aitken's array]]'''
 
=={{header|Ada}}==