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

Post by brianfry713 » Wed Aug 07, 2013 11:00 pm

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

Post by techbd123 » Sat Aug 17, 2013 2:54 pm

Thanks Guru! Brianfry

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

Re: Presentation error on 160

Post by vsha041 » Wed Mar 26, 2014 10:34 pm

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

Post by vsha041 » Wed Mar 26, 2014 10:34 pm

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

Post by RedCode119 » Sun Aug 17, 2014 1:14 pm

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: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 160 - Factors and Factorials

Post by lighted » Mon Aug 18, 2014 4:13 am

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
Your 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  110012451124297438  1879047287917443473460340792421473239042147323904124515242638601245168
Don't forget to remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

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

Re: 160 - Factors and Factorials

Post by uradura » Thu Jan 08, 2015 4:08 pm


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

Re: 160 - Factors and Factorials

Post by brianfry713 » Fri Jan 09, 2015 12:16 am

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

Post by NAbdulla » Thu Jan 22, 2015 2:34 pm

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

Post by brianfry713 » Fri Jan 23, 2015 1:32 am

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

Post by Tarol Hasan » Thu Jul 16, 2015 7:46 pm

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

Post Reply

Return to “Volume 1 (100-199)”