How to resolve the algorithm Bell numbers step by step in the Arturo programming language
How to resolve the algorithm Bell numbers step by step in the Arturo programming language
Table of Contents
Problem Statement
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 Bn is the number of partitions of a set of size n where order of the 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}.
A simple way to find the Bell numbers is construct a 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.
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.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Bell numbers step by step in the Arturo programming language
Source code in the arturo programming language
bellTriangle: function[n][
tri: map 0..n-1 'x [ map 0..n 'y -> 0 ]
set get tri 1 0 1
loop 2..n-1 'i [
set get tri i 0 get (get tri i-1) i-2
loop 1..i-1 'j [
set get tri i j (get (get tri i) j-1) + ( get (get tri i-1) j-1)
]
]
return tri
]
bt: bellTriangle 51
loop 1..15 'x ->
print [x "=>" first bt\[x]]
print ["50 =>" first last bt]
print ""
print "The first ten rows of Bell's triangle:"
loop 1..10 'i ->
print filter bt\[i] => zero?
You may also check:How to resolve the algorithm Word wheel step by step in the APL programming language
You may also check:How to resolve the algorithm MD4 step by step in the Nim programming language
You may also check:How to resolve the algorithm Write entire file step by step in the Groovy programming language
You may also check:How to resolve the algorithm Sorting algorithms/Counting sort step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Sorting algorithms/Permutation sort step by step in the Ursala programming language