How do I program this?

example:

n = 30

265-(n-1) = 265-(29) = 236

*How do I program the product from 265 down to 265-(n-1)?

265*264*263*262*261*260*.....*240*239*238*237*236 =

It is a factorial calculation but I'm not doing the entire 265!.

Thank-you.
Sounds like you want the permutation operation: 265 nPr 30. This is mathematically equivalent to 265!/(265-30)!.
When working with factorials like that understanding nCr and nPr can come in handy.

nPr here is the exact operation you are looking to do
this case would 265 npr 30 when n=30
265 npr n if trying to generalize what you asked

Quick explanation of commands:
nCr - Combinations. n objects in r positions where order does not matter
ABC BAC CAB etc all count as the same combination
nPr - Permutations. n objects in r positions where order does matter
ABC BAC CAB count as 3 seperate permutations.

What will really help in this case are the formulas for these
nPr = n! / (n-r)!
nCr = n! / ( (n-r)! (r!) )

http://tibasicdev.wikidot.com/npr for npr
http://tibasicdev.wikidot.com/ncr for ncr
Both are found under Math->Probability

as another piece of trivia 265! is the same as 265 nPr 265.
Awesome. That worked. Thank-you!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement