unique_combinations_counter_rec ( )

Function stats

Average user rating
128
228
9999
Support
FileMaker 8.0 +
Date posted
25 May 2009
Version
1
Recursive function
Yes

Author Info
 Eric

7 functions

Average Rating None

author_avatar



 

Function overview

Prototype

unique_combinations_counter_rec  ( number_values )


Parameters

number_values  number between 0 and 212


Description

Tags:  Statistics   Number  

Same as "unique_combinations_counter ()" but recursive.
This function calculates the number of unique combinations of n values (WARNING 212 Values Max)
ex :
list = "a¶b¶c¶d" ----> 4 values
combinations = "a¶b¶c¶d¶ab¶ac¶ad¶bc¶bd¶cd¶abc¶abd¶acd¶bcd¶abcd"
---> 15 unique values (without aa, abc=bca=cab=acb...)

Examples

Sample input

unique_combinations_counter_rec(4)
unique_combinations_counter_rec(50)


Sample output

15
1125899906842623

 

Function code

/* unique_combinations_counter_rec (number_values)

by Eric Plassot


v.1, May 2009


This function calculates the number of unique combinations of n values (WARNING 212 Values Max)
ex :
list = "a¶b¶c¶d" ----> 4 values
combinations = "a¶b¶c¶d¶ab¶ac¶ad¶bc¶bd¶cd¶abc¶abd¶acd¶bcd¶abcd"
---> 15 unique values (without aa, abc=bca=cab=acb...)

RECURSIVE
*/
if(
number_values > 212;
"error (number_values>212)";
Case(
$Counter < number_values;
let(
[
$n_combcum = Cas( $Counter = ""; ""; $n_combcum );
$Counter = $Counter + 1;
$val = Combination( number_values; $Counter );
$n_combcum = $n_combcum + $val
];
unique_combinations_counter_rec( number_values )
);
let( $Counter = ""; $n_combcum )
)
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/228

    Prototype: unique_combinations_counter_rec( number_values )
    Function Author: Eric (http://www.fmfunctions.com/mid/128)
    Last updated: 25 May 2009
    Version: 1

*/
// ===================================

 

 

 

 


Login or register to comment

Create a new account with fmcustomfunctions.com or login to post a comment.

 

 

 

Top Tags

Text Parsing  (24)
List  (19)
XML  (15)
Format  (14)
Date  (12)
Debug  (12)
Layout  (11)
Variables  (10)
Filter  (9)
Layout Objects  (6)
ValueIterator  (6)
Recursive  (5)
Dev  (5)
Interface  (5)
Text  (5)
Number  (5)