Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

List of possible combinations for x numbers.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2007, 05:19 PM
EdQas's Avatar
Junior Member
 
Join Date: Aug 2007
Location: French Riviera
Posts: 35
Red face List of possible combinations for x numbers.

Hi everybody,
If I have 3 numbers, the list of all combinations is :
3*2*1 = 6 possibilities :
123 132 213 231 312 321

If I have 7 numbers, there are 5040 possibilities (7*6*5*4*3*2*1).

: how can i list all of these possibilities ?

Thank you for the help.

Ed
__________________

Dell Axim x51v
Reply With Quote
  #2 (permalink)  
Old 10-06-2007, 06:04 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Do you mean something like:
Code:
Sub App_Start
    
Msgbox(Factorial(7))
End Sub

Sub Factorial(n)
    f = 
1
    
For i = 2 To n
        f = f * i
    
Next
    
Return f
End Sub
Reply With Quote
  #3 (permalink)  
Old 10-06-2007, 06:12 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

I think he is looking for something like this:

Code:
Sub Globals
End Sub

Sub App_Start
    
' Create a Form1 and add a ListBox1
    FillListBox("1234567""")
    Form1.Show
    
Msgbox(ListBox1.Count)    
End Sub

Sub FillListBox(value, combi)
    
If value = "" Then
        ListBox1.Add(combi)
    
Else
        
For i = 0 To StrLength(value) - 1
            FillListBox(StrRemove(value, i, 
1), combi & SubString(value, i ,1))        
        
Next
    
End If
End Sub

specci48
Reply With Quote
  #4 (permalink)  
Old 10-07-2007, 09:18 AM
EdQas's Avatar
Junior Member
 
Join Date: Aug 2007
Location: French Riviera
Posts: 35
Thumbs up Hurra !

Thank your Erel and Specci !
The example of Specci was what i was searching for.
Once more, many thanks.
Have a nice sunday.
Ed
__________________

Dell Axim x51v
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
B4PObject numbers Louis Questions (Windows Mobile) 1 05-14-2008 08:51 PM
Combinations application Stellaferox Share Your Creations 0 02-21-2008 08:24 PM
Combinations Sub: choose(n,k) Stellaferox Code Samples & Tips 2 02-21-2008 06:51 PM
Combinations function derez Share Your Creations 0 02-04-2008 11:40 AM
code to write out combinations e.g. (10 choose 3) Stellaferox Questions (Windows Mobile) 4 02-04-2008 05:51 AM


All times are GMT. The time now is 11:19 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0