রবিবার, ২৮ আগস্ট, ২০১৬

UVA 160 - Factors and Factorials

#include<stdio.h>
main()
{
long int i,j,n,k=0,ar[1000]={0},k1;
for(i=2;i<=100;i++)
{
long count=0;
for(j=2;j<=i;j++)
{
if(i%j==0)
{
count++;
}
}
if(count==1)
{
ar[k++]=i;
}
}
long n1,k2,i1,ar1[1000]={0},k3;
while(scanf("%ld",&n1)!=EOF)
{
if(n1==0)
break;
long ar2[1000]={0};
for(i=2;i<=n1;i++)
{
k2=i;
i1=0,k3=0;
while(k2!=1)
{
while((k2%ar[i1])==0)
{
k2=k2/ar[i1];
ar2[ar[i1]]++;
}
//printf("%ld ",i1);
i1++;

}
}
printf("%3d! =",n1);
long count=0;
for(long ii=2;ii<=n1;ii++)
{
if(ii==53)
printf("\n      ");
if(ar2[ii]!=0)
{
printf("%3ld",ar2[ii]);
count++;
}

}
printf("\n");
}

}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন

Factory Pattern

Factory Method  is a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alte...