2013年12月1日 星期日

安裝fumefx 3.5.1之後沒出現在3ds max 2014面板

1.找到C:\Program Files\Autodesk\3ds Max 2014\en-US\plugin.ini <3DSMAX安装目錄>
2.打開plugin.ini,在最後增加:

afterworkscommon=E:\CG Software\3ds Max Design 2014\plugins\afterworks\common
fumefx=E:\CG Software\3ds Max Design 2014\plugins\afterworks\fumefx
afterworksoptional=E:\CG Software\3ds Max Design 2014\plugins\afterworks\optional


3.就會出現fumefx在面板

2013年11月17日 星期日

領袖的十二項特質

世界領袖教育基金會
領袖十二項特質
1.強健的體魄
每周五早上去重訓室
2.生龍活虎的活力
活動組
3.高尚的品格
不逃票
4.慈悲的愛心
侵襲菲律賓海燕颱風捐款
5.國際的宏觀
甘比亞斷交
6.辯才無礙的口才
鼓勵參加培訓班
7.領導統御的能力
領導營隊
8.超高的智慧
預知未來的能力
9.特殊的魅力
待開發
10.協調溝通的能力
社團運作
11.具備企劃、執行、依進度完成目標的能力
規劃家族
12.要有禪的修養
每天禪定60分鐘

2013年11月12日 星期二

halo effect and stencil buffer



         glEnable(GL_STENCIL_TEST);

         glStencilFunc(GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
         glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
         glStencilMask(0xFF); // Write to stencil buffer
         glDepthMask(GL_FALSE); // Don't write to depth buffer
         glClear(GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (0 by default)
glDisable(GL_BLEND);

//draw原來物件

         glStencilFunc(GL_EQUAL, 0, 0xFF); // Pass test if stencil value is 1
         glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);      
         glStencilMask(0x00); // Don't write anything to stencil buffer

glEnable(GL_BLEND);
//draw halo object
         glDepthMask(GL_TRUE);







2013年10月23日 星期三

compiler第九章Machine-Independent Optimization

code optimization分成兩種 local和global

local code optimization在section 8.5

大多數的global optimization是data-flow analysis

9.1 The Principal Sources of Optimization

Semantics-Preserving Transformations
1)common-subexpression elimation
2)copy propagation
3)dead-code elimination
4)constant folding
5)code motion
6)induction variables and reduction in strength

2013年9月8日 星期日

GL_TRIANGLES和GL_TRIANGLE_FAN

有六個點
{ 0.0, 0.0 }, { 1.0, 0.0 }, { 1.0, 1.0 } ,{0.0,1.0},{2.0,1.0},{2.0,2.0}

GL_TRIANGLES

 glDrawArrays(GL_TRIANGLES, 0, 6);

畫兩個三角形



GL_TRIANGLE_FAN
glDrawArrays(GL_TRIANGLE_FAN, 0, 6);

第三個點共點

2013年9月5日 星期四

動態改變glsl uniform的time值

Uniforms[4].value[0]+=0.01;    //time
SetUniformValue(Uniforms);

glUseProgram(p,Uniforms);

2013年6月26日 星期三

Javascript cookie

   function SetCookie(name,value){
                        var NameString = name + "=" + value;
                                document.cookie = NameString;
                        }

    function GetCookie(name) {
                        var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
                        if(arr != null) return unescape(arr[2]); return null;
                        }

2013年6月9日 星期日

導覽列如何加入圖片

css樣式標連結用class .feed
.navi li ul li .feed{
display:block;
height:50px;
width:50px;
background:url("img/apple.png") left no-repeat;
}


ul class標籤用feed代表
<ul class="feed"><li><a herf="#">餵食</a></li></ul></li>





2013年6月6日 星期四

物件位置更新

先宣告一個Object3D 物件
var myfish=THREE.Object3D;

...

loader=...

myfish=object;   //object是blender obj mtl load進來的物件
...

update(){
      myfish.translateX=10;          平移10個單位
}


在要呼叫update位置的地方呼叫它

2013年5月25日 星期六

Three.js 如何loading blender obj mtl檔

在blender export obj檔
會產生.obj .mtl

在利用three.js load

var loader = new THREE.OBJMTLLoader();
                                loader.addEventListener( 'load', function ( event ) {

                                        var object = event.content;

                                        object.position.y = 0;
                                        scene.add( object );

                                });
                                loader.load( 'obj/male02/monkey.obj', 'obj/male02/monkey.mtl' );


2013年3月24日 星期日

Compiler(1)


第一章

Programming languages are notations for describing computations to people
and to machines.
It first must be translated into a form in which it can be executed by a computer.
The software systems that do this translation are called compilers.

a compiler is a program that can read a program in one lan­
guage - the source language - and translate it into an equivalent program in
another language - the target language.


f we open up this box
a little, we see that there are two parts to this mapping: analysis and synthesis .The analysis part
is often called the front end of the compiler; the synthesis part is the back end. 

2013年3月20日 星期三

OpenCL筆記

OpenCL主要分成四個部份

Platform model -- device 和 host

Execution model -- kernel如何在device上執行

Memory model -- abstract memory hierarchy

Programming model -- 定義concurrency model如何map 到physical hardware


(1) Initialize platforms

clGetPlatformIDs(...,...,...);

(2)Initialize devices

clGetDeviceIDs(...,...,...,...,...);

(3) Create a context

clCreateContext(...,...,...,...,...,...,...);

(4) Create a command queue

clCreateCommandQueue(...);

(5) Create device buffers

clCreateBuffer(...);

(6) Write host data to device buffers

clEnqueueWriteBuffer(...);

(7) Create and compile the program

clCreateProgramWithSource(...);

clBuildProgram(...);

(8) Create the kernel

clCreateKernel(...);

(9) Set kernel arguments

clSetKernelArg(...);

(10) Configure the work-item structure

size_t globalWorkSize[1];

globalWorkSize[0]=2048;

(11) Enqueue the kernel for execution

clEnqueueNDRangeKernel(...);

(12) Read output results to host

clEnqueueReadBuffer(...);

(13) Release OpenCL Resources

clRealeaseKernel(...);
clRealeaseProgram(...);
...







2013年3月13日 星期三

物件導向(1)


#include <stdio.h> → include interface ↔ 沒有include implementation
int main()
{
printf(“Hello World!\n”); → 第一個引數format string

return 0;
}

preprocessing(macro) → compiling → linking (才需要知道implementation 函式庫)
static dynamic

posix (portable operation system interface)
包含各種platform的實作

#include <stdio.h>
int stk[100]; → scope的問題 加上static解決問題
int sp = -1;
void push(int x) → 兩個stack 的問題 float double型別的stack問題
{            沒有encapsulation的問題
stk[++sp]=x;
}
int pop()
{
return stk[sp--];
}

ADT(Abstract Data Type)= Data + Operators(用來manipulate Data操作)

C++克服C的地方
encapsulation
inheritance(reuse)
polymorphism(switch)

資料庫(3)


DB2 & SQL

每種query language 都有DDL and DML
a base table is “real” table實體存在
a view is a “virtual” table

2013年3月5日 星期二

OpenCL(1) vector add



//vector add 副程式  類似glsl中 fragment shader 和vertex shader呼叫方式


const char* programSource =
"__kernel                 \n"
"void vecadd(__global int *A,\n"
"            __global int *B,\n"
"            __global int *C) \n"
"{\n"

"   // Get the work-item unique ID                \n"
"   int idx = get_global_id(0);                   \n"
"\n"
"   // Add the corresponding locations of        \n"
"   // 'A' and 'B', and store the result in 'C'. \n"
"   C[idx] = A[idx] + B[idx];\n"
"}\n"
;



main主程式
...
kernel = clCreateKernel(program, "vecadd", &status);    //inline 方式call vecadd
...


Compile方法

g++ vectoradd.c -I/usr/local/cuda-5.0/include -L/usr/local/cuda-5.0/lib64 -lOpenCL

資料庫(2)


第二章 Data Model

Data Model:A set of concepts to describe the structure of a database, and certain constraints that the database should obey.

Components of Data Model
1.Structures
2.Operations
3.Integrity Constraints

Data Model為了將資料抽象化,storage detail隱藏

Relational Data Model
Hierarchical Data Model
Network Data Model

Primary Key:滿足uniquenessminimalitycandidate key
Foreign key:a foreign key is an attribute of relation R2 whose values are refer to the primary key of some relation R1.

資料庫(1)


第一章 Why using a DB?
Database System:DBMS+data
一個資料庫就是一群有關系的資料所成的集合

Operations on a DB
1.add/remove files
2.insert/delete/update data in existing files
3.retrieve data 最常用read-only (select)

field(attribute) → record(tuple) → file

一個資料庫系統能提供資料分享,整合,一致性,標準化,安全限制及避免重複資料的儲存

(ADV.)
1.Redundancy
2.Inconsistency(Avoided)
3.Shared
4.Standards
5.Security restrictions
6.Integrity
7.Conflicting requirements
8.Data Independence

an architecture for a DB
Three layers:Internal, Conceptual, External → 資料庫有三層

Internal schema → storage structures and access paths
Conceptual schema → structure and constraints
External schema → user views

1.Logical Data Independence
2.Physical data Independence
3.Mapping

Data Definition Language(DDL):Used by the DBA and database designer to specify the conceptual schema of a database.
Data Manipulation Language(DML):Used to specify database retrievals and updates.
DML commands(data sub-language)

Objects of Database Design
1.easy to use
2.easy to maintain
3.cost effective

2013年3月3日 星期日

安裝cuda 5.0 on Ubuntu 12.04


sudo ln -s /usr/lib/x86_64-linux-gnu/libglut.so /usr/lib/libglut.so

 sudo ./cuda_5.0.35_linux_64_ubuntu11.10-1.run


export PATH=$PATH:/usr/local/cuda/bin:/usr/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64:/lib


2013年2月5日 星期二

電磁學(1)


Volume charge density ρv=∆v->無限大lim∆q/∆v  (C/m^3)
surface charge density  ρs=∆s->無限大lim∆q/∆s (C/m^2)
line charge density  ρl=∆l->無限大lim∆q/∆l (C/m)

電流 I=dq/dt (C/s or A)
D=∈E
H=1/u*B

u0=4pi*10^-7
∈0=1/36pi * 10^-9
C^2=1/(∈0u0)

Qt使用glut

在pro檔
Qt += opengl
libs += -L/usr/include/lib -lglut -lGLU

2013年2月3日 星期日

github上傳檔案

1)new repo 在首頁右上角
2)git add *(加入所選檔案)
3)git commit -m 'commit 訊息'
4)git push

2013年2月2日 星期六

作業系統(3)


第三章 Process Concept

Current-day computer systems allow multiple programs to be loaded into memory and executed concurrently. This evolution required firmer control amd more compartmentalization of various programs;and these needs resulted in the notion of a process, which is a program in execution. A process is the unit of work in modern time-sharing system.

A process is more than the program code, which is sometimes known as the text section. It also includes the current activity, as represented by the value of the program counter and the contents of processor's registers. A process generally also includes the process stack and a data section, which contains global variables. A process may also include a heap, which is memory that is dynamically allocated during process run time.

As a process executes, it changes state: The state of a process is defined in part by the current activity of that process.

1.New – The process is being created.
2.Running – Instructions are being  executed.
3.Waiting – The process is waiting for some event to occur.
4.Ready – The process is waiting to be assigned to a processor.
5.Terminated – The process has finished execution.

Each process is represented in the operating system by a process control block(PCB) – also called a task control block.
1. Process state
2. Program counter
3. CPU registers
4. CPU-scheduling information
5. Memory-management information
6. Accounting information  – the amount of CPU and real time used, time limits, account numbers, job or process numbers, and so on.
7. I/O status information.


The operating system must select, for scheduling purposes, processes from these queues in some fashion. The selection process is carried out by the appropriate scheduler.


A socket is defined as an endpoint for communication. A pair of processes communicating over a network employ a pair of sockets.
The RPC(Remote Procedure Calls) was designed as a way to abstract the procedure-call mechanism for use between systems with network connections.

離散數學(2)-1


Show that for primitive statements p,q

p V q(p xor q) ↔ (p^~q)V(~p^q) ↔ ~(p ↔ q)

p
q
p V q
p^~q
~p^q
(p^~q)V(~p^q)
p → q
q → p
p↔q
~ p↔ q
0
0
0
0
0
0
1
1
1
0
0
1
1
0
1
1
1
0
0
1
1
0
1
1
0
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0

離散數學(8)


第八章 The Principle of Inclusion and Exclusion

The Principle of Inclusion and Exclusion. Cosider a set S, with |S|=N, and coditions ci, 1<=i<=t, each of which way be satisfied by some of the elements of s of S. The number of elements of S that satisfy none of the conditions ci, 1<=i<=t, is denoted by N'=N(c1'c2'c3'...ct') where

N'=N-[N(c1)+N(c2)+...+N(ct)]+[N(c1c2)+n(c1c3)+...+N(c1ct)+N(c2c3)+...+N(ct-1ct)]-[N(c1c2c3)+N(c1c2c4)+...+N(c1c2ct)_N(c1c3c4)+...+N(c1c3ct)+...+N(ct-2ct-1ct)]+...+
(-1)^tN(c1c2c3...ct)

N'=N-1<=i<=t∑N(ci)+1<=i<j<=t∑N(cicj)-1<=i<j<k<=t∑N(cicjck)+...+
     (-1)^tN(c1c2c3...ct)

2013年1月29日 星期二

離散數學(7)


第七章 Relations: The Second Tine Around

A relation R on a set A is called reflexive(反身性) if for all x ε A (x,x) ε R

Relation R on set A is called symmetric(對稱性) if(x,y) εR → (y,x) ε R for
all x,y ε A

For a set A, a relation R on A is called transitive of, for all x,y,z ε A, (x,y),(y,z) ε R → (x,z) ε R.(So if x “is related to” y, and y “is related to” z, we want x “related to” z, withy playing the role of “intermediary”.

Given a relation R on a set A, R is called antisymmetric if for all a,b εA ,(aRb and bRa) → a=b

A relation R on a set A is called a partial order, or a partial ordering relation, if R is reflexive, antisymmetric, and transitive.

If A, B, and C are sets with R1cAxB and R2c BxC, then the composite relation R1◦R2 is a relation from A to C defined by  R1◦R2={(x,z)|x εA,
z ε C, and thereexists y ε B with (x,y) εR (y,z) εR2}

長方桌排列

有10個人 在長方桌作排列

一邊可坐3人 一邊可坐2人

共有10! /2種排列

作業系統(2)


第二章 System Structures

An operating System provides the environment within which programs are executed.

User interface. Almost all operating systems have a user interface(UI). The interface cam take several forms. One is DTrace Command-line interface(CLI), which uses text commands and a method for entering them.

Another is a batch interface, in which commands and directives to control those commands are entered into files, and those files are executed.

Most commonly, a graphical user interface(GUI) is used. Here, the interface is a window system with a pointing device and direct I/O, choose from menus, and make selections and a keyboard to enter text.

On systems with multiple command interpreters to choose from, the interpreters are known as shells.

System calls provide an interface to the services made available by an operating system.

System programs, also known as system utilities, provide a convinient environment for program development and execution.

The kernel has a set of core components and links in additional services either during boot time or during run time. Such a strategy uses dynamically loadable modules and is common in modern implementations of UNIX.

Seven types of loadable kernel modules
1. Scheduling classes
2. File systems
3. Loadable system calls
4. Executable formats
5. STREAMS modules
6. Miscellaneous
7. Device and bus drivers.

2013年1月27日 星期日

離散數學(6)


第六章 Languages: Finite State Machines

If is an alphabet and n ε Z+, we define the powers of ∑ recursively as follows:
1)∑1=∑
2)∑^n+1={xy|x ε ∑, y ε ∑^n} where xy denote the juxtaposition of x and y

For a alphabet ∑ we define ∑0={λ},where λ denotes the empty string—that is, the string consisting of no symbols taken from ∑.

If ∑ is an alphabet
a)∑ +=n=1 to 無限大U∑ n=Un ε z+∑ n
b)∑ *=n=0 to無限大 U∑ n

2013年1月26日 星期六

離散數學(5)


第五章 Relations and Functions

5.1 Cartesian Products and Relations

For sets A,B the Cartesian product, or cross product, of A and B is denoted by AxB and equals{(a,b)|a ε A,b ε B}.

For sets A,B, any subset of AxB is called a (binary) relation from A to B. Any subset of AxA is called a (binary) relation on A.

For nonempty sets A, B, a function, or mapping, from A to B, denoted
f :A → B, is a relation from A to B in which every element of A appears exactly once as the first component of an ordered pair in the relation.

For the function of f:A → B, A is called the domain(定義域) of f and B the codomain(對應域) of f. The subset of B consisting of those elements that appear as second component in the ordered pairs of f is called the range(值域) of f and is also denoted by f(A) because it is the set of images under f.

A domain f:A → B is called one-to-one, or injective, if each element of B appears at most once as the image of an element of A.

A function of f:A → B is called onto, or surjective, if f(A)=B—that is, if for all b ε B there is at least one a ε A with f(a)=b.

作業系統(1)


第一章 Introduction

An operating systen is a program that manages the computer hardware.
The hardware—the central processing unit(CPU), the memory, and the input/ouput(I/O) devices – provides the basic computers resources for the system.

The application programs—such as word processors, spreadsheets, compiler, and Web browsers—define the ways in which these resources are used to solve users' computing problems.

The operating system controls the hardware and coordinate its use among various application programs fir the various users.

A more common definition, and the one that we usually follow, is that the operating system is the one program running at all times on the computer—usually called the kernel.

Softeare may trigger an interrupt by executing a special operation called a system call.

On a single-processor system, there is one main CPU capable of excuting a general-purpose instuction set, including instructions from user processes.

Multiprocessor systems(also known as parallel systems or tightly coupled systems) are growing in importance. Such systems have two or more processors inclose communication, sharingthe computer bus and sometimes the clock, memory, and peripheral devices.

A trap (or an exception) is software-generated interrupt caused either by an error(for example, division by zero or invalid memory access) or by a specific request from a user program that an operating-system service be performed.

User mode amd kernel mode(also called supervisor mode, system mode, or privileged mode). A bit, called the mode bit, is added to the hardware of the computer to indicate the current mode : kernel(0) or user(1).

Embedded systems almost always run real-time operating system. A real-time system is used when rigid time requirements have been placed on the operation of a processor or the flow of data.


The operating system is responsible for the following activities in connection with process management

i)Scheduling processes and threads on the CPUs
ii)Creating and deleting both user and system processes
iii)Suspending and resuming processes
iv)Providing mechanisms for process synchronization
v)Proving mechanisms for process communication.





2013年1月24日 星期四

離散數學(4)


第四章 Properties of the integers: Mathematical Induction

All that is needed is for the open statement S(n) to be true for some first element n0 ε Z so that the induction process has a starting place. We need the truth of S(n0) for our basis step. The integer n0 could be 5 just as well as 1. It could even be zero or negative because the set Z+ in union with {0}{ or any finite set of negative integers is well ordered.

Principle of Mathematical Induction
[S(n0) ^ [all k>=n0[s(k) → s(k+1)]]] → all n >=no s(n)

Principle of Strong Mathematical Induction
a) If s(n0),s(n0+1), s(n0+2)...,s(n1-1),s(n1) are true
b)If whenever s(n0) s(n0+1)...s(k-1)and s(k) are true for some k ε z+, where k>=n1, then the statement s(k+1) is also true;then s(n) is true for all n>=n0

If a,b ε z and b=\0 , we say that b divides a and we write b|a, if there is an integer n such that a=bn, where this occurs we say that b is a divisor(因數), or a is a multiple(倍數) of b.

a) 1|a and a|0
b) [(a|b)^(b|a)] → a=+-b
c)[(a|b)^(b|c)] → a|c
d) a|b → a|bx for all x ε Z
e) If x=y+z for some x,y,z ε Z, and a divides two of the three integers x,y and z, then a divides the remaining integer.
f)[(a|b)^a|c)] → a|(bx+cy) for all x,y ε Z
g)For 1<=i<=n let ci ε Z. If a divides each ci, then a|(c1x1+c2x2+...+cnxn), where xi ε Z for all 1<=i<=n

2013年1月23日 星期三

離散數學(3)


第三章 Set Theory

A set should be well-defined collection of objects. These objects are called elements and we said to be members of the set.

If C,D are sets from a universe U, we say that C is a subset of D and write C c D or D c C , if every element of C is an element of D. If , in addition, D contains an element that is not in C, then C is called a proper subset of D, and this is denoted by C c D

for A,B c U we define the flowing

a) A U B( the union of A and B) = {x|x ε A V ε B}
b) AB( the intersection of A and B) = {x| x ε A ^ ε B}
c)AΔB(the symmetric difference of A and B ) = {x| (x ε A V ε B) ^
x not ε AB}={x|x ε AUB ^ x not ε AB}

2013年1月22日 星期二

離散數學(2)


第二章 Fundamentals of Logic

In the development of any mathematical theory, assertions are made in the form of sentences. Such verbal or written assertions, called statements (or propositions), are declarative sentences that are either true or false.

1)Transform a given statement p into the statement ¬p, which denotes its negation and is read “Not p.”

2)
a) Conjunction:The conjunction of the statements p,q is denoted by p^q, which is read “p and q.”
b) Disjunction: The expression p V q denotes the disjunction of the statements p,q and is read “p or q.”
c)Implication: We say that “p implies q” and write p->q to designate the statement, which is the implication of q by p.
i)If p, then q.
ii)p is sufficient for q
iii)p is sufficient condition for q
    iv)q is necessary for p
    v)q is a necessary condition for p
    vi) p only if q
    d) Bi-conditional: The bi-conditional of two state¬ments p,q is denoted by
    p ↔ q, which is read “p if and only if q” or “p is necessary and sufficient for q”
    p if and only if q” 可縮寫成 “p iff q”
p q p^q p V q p V q p->q q ↔ p
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1¬ 1

A compound statement is called a tautology if it is true for all truth value assignments for its component statements. If a compound statement is false for all such assignments, then it is called a contradiction.


¬
Two statements s1,s2 are said to be logically equivalent, and we write
s1 ↔ s2, when the statement s1 is true if and only if the statement s2 is true.
¬
Let s be a statement. If s contains no logical connectives other than ^ and V, then the dual of s denoted sd, is the statement obtained from s by replacing each occurrence of ^ and V by V and ^, respectively, and each occurrence of T0 and F0 by F0 and To, respectively.

The principle of duality, let s and t be statements that contain no logical connectives other than ^ and V.
if s ↔ t, than sd ↔ td

p->q ↔ ~p V q

The statement ¬q → ¬p is called contrapositive of the implication p → q

The statement q → p is called the converse of p → q
¬p → ¬q is called the inverse of p → q

The contrapositive(否逆)¬q → ¬p
The converse(): q → p
The inverse () : ¬p → ¬q

When we write allxp(x)->exist x p(x) we are saying that the implication allxp(x) → exist x p(x) is a logical implication.


Two substitution rules
1)Suppose that the compound statement P is a tautology. If p is primitive statement that appears in P and we replace each occurrence of p by the same q, then the resulting compound statement P1 is also a taotology.
2)Let P be a compound statement where p is an arbitrary statement that appears in P, and let q be a statement such that q ↔ p, Suppose that in P we replace one or more occurences of p by q. Then this replacement yields the compound statement P1. Under these circumstances P1 ↔ P.

p → q   <=> ~p V q  <=> ~q → ~p




離散數學(1)


第一章 Fundamental Principles of Counting

Enumeration, or counting, may strike one as an obvious process that a student learns when first studying arithmetic.

Our study of discrete and combinatorial mathematics begins  with two basic principles of counting: the rules of sum and product.

The Rule of Sum: If a first task con be performed in m ways, while a second task can be performed in n ways, and the two task cannot be performed simultaneously, then performing either task can be accomplished in any one of m+n ways.

The Rule of Product: If a procedure can be broken down into first and second stages, and if there are m possible outcomes for first stage and if, for each of these outcomes, there are n possible outcomes for the second stage, then the total procedure can be carried out, in the designated order, in mn ways.

For an integer n >= 0, n factorial ( denoted n¦)
is defined by 0¦=1
                         n¦=(n)(n-1)(n-2)...(3)(2)(1) for n >= 1

Given a collection of n distinct objects, any(linear) arrangement of these objects is called a permutation of the collection.

If there are n distinct objects and r is an integer, with 1<=r<=n, then by the rule of product, the number of permutation of size r for the n objects

p(n,r)=n*(n-1)*(n-2)*...*(n-r+1)
=(n)(n-1)(n-2)...(n-r+1)*(n-r)(n-r-1)...(3)(2)(1)/((n-r+1)*(n-r)(n-r-1)...(3)(2)(1))
=n¦/(n-r)¦

If there are n objects with n1 indistinguishable objects of a first type, n2  indistinguishable objects of a second type,..., and nr  indistinguishable objects of a nth type, where n1+n2+...+nr=n
then there are n¦/(n1¦n2¦...nr¦) (linear) arrangements of the given n objects.

If we start with n distinct objects, each selection, or combination, of r of these objects, with no reference to order,corresponds to r¦ permutations of size r from the n objects. Thus the number of combinations of size r from a collection of size n is

C(n,r)=P(n,r)/r¦=n¦/(r¦(n-r)¦)  0<=r<=n

The binomial Theorem
(x+y)^n=(n,0)x^0y^n+(n,1)X^1y^n-1+(n,2)X^2y^(n-2)+...+(n,n-1)x^(n-1)y^1+(n,n)x^ny^0=form k=0 to n∑(n,k)x^ky^(n-k)