160 - Factors and Factorials

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Presentation error on 160

Don't print a space at the end of a line.
Check input and AC output for thousands of problems on uDebug!

techbd123
New poster
Posts: 14
Joined: Tue Aug 06, 2013 3:42 pm

Re: Presentation error on 160

Thanks Guru! Brianfry

vsha041
New poster
Posts: 35
Joined: Wed Feb 12, 2014 10:04 am

Re: Presentation error on 160

Thanks for the edge case Brian. And those getting runtime error - looks like input contains number greater than 100 as well.

vsha041
New poster
Posts: 35
Joined: Wed Feb 12, 2014 10:04 am

Re: 160 - Factors and Factorials

Those getting runtime error, looks like input contains number greater than 100 so generate little extra primes.

RedCode119
New poster
Posts: 13
Joined: Tue Jul 08, 2014 7:14 pm

Re: 160 - Factors and Factorials

I can't find my problem will you help me here's my code
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
long n,i,j,k,m;
while(cin>>n, n!=0)
{
long fac[25]={0},prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
for(i=2; i<=n; i++)
{
k=i;
while(k>=1)
{
for(j=2; j<=k; j++)
{
if(k%j==0)
{
for(m=0;m<25;m++)
{
if(j==prime[m])
{
fac[m]++;
break;
}

}
break;
}

}
k=k/j;
}

}
int count=0;
printf("%3d! =",n);
for(i=0;fac!=0;i++)
{
if(count==15)
printf("\n%6c",' ');
printf("%3d",fac);
count++;
}
printf("\n");

}
return 0;
}

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 160 - Factors and Factorials

Input

Code: Select all

``````100
0
``````
Acc output

Code: Select all

``````100! = 97 48 24 16  9  7  5  5  4  3  3  2  2  2  2
1  1  1  1  1  1  1  1  1  1
``````

Code: Select all

``````100! = 97 48 24 16  9  7  5  5  4  3  3  2  2  2  2
1  1  1  1  1  1  1  1  1  110012451124297438  1879047287917443473460340792421473239042147323904124515242638601245168
``````
Don't forget to remove your code after getting accepted.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

New poster
Posts: 11
Joined: Thu Jan 01, 2015 10:31 am

Re: 160 - Factors and Factorials

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 160 - Factors and Factorials

It looks like you figured it out.
Check input and AC output for thousands of problems on uDebug!

NAbdulla
New poster
Posts: 31
Joined: Wed Jul 30, 2014 3:40 pm
Contact:

160 - Factors and Factorials why PE

Help Help.....
This code gives PresentationE
Last edited by NAbdulla on Fri Jan 23, 2015 6:39 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 160 - Factors and Factorials

Next time post in the existing thread.
Look at the spacing in the sample output.
Check input and AC output for thousands of problems on uDebug!

Tarol Hasan
New poster
Posts: 1
Joined: Fri Sep 12, 2014 10:41 am

Re: 160 - Factors and Factorials

http://ideone.com/N6jRqA
what's wrong???