i am doing the same thing without using array long long int res = 1; int j = 2; for(int i = n-k+1; i <= n; i++){ res *= (long long int)i; while(j <= k && res%j == 0){ res/=j; j++; } }
On Tue, Jun 21, 2011 at 4:25 PM, kartik sachan <kartik.sac...@gmail.com> wrote: > > @ sunny i am not getting ur apporach > but i am thinking like this...... > taking an array from and intilize it to n to n-r > > a[1000]; > int k=0; > for(int i=n;i>=n-r;i--) > a[k++]=i; > > for(int y=n-r;y>1;y--) > for(j=0;j<k;j++) > if(a[j]%y==0) > {a[j]=a[j]/y;break;} > > > for example we take 7c3 > > > so first array is intilize to {7,6,5,4} > then we check divisibilty by {3,2} > so 6 is divisible by 3 so put 6/3 back in array 2 > so finally 7*2*5*2; > > -- > You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.