i have this and i can not solve it plz l do not have time :(


Write a program that print the prime factorization of all the number n between 2 and 100 .if n is a prime , your program writes that it is so . otherwise it should list all the prime factor of it . Take a look at this output :
2 is a prime .
3 is a prime .
4 is the multiplication of : 2 2.


100 is the multiplication of : 2 2 5 5.
Your program should include the following functions ;

bool isprime (int n) returns true if the given argument is a prime number. Remember , n is a prime iff if cannot be divided except by 1 and by itself . note that 1 is not prime .

int minfactor (int n) returns the smallest prime number that divides n . if n is a prime minfactor (n) return n .
void printfactors (int n) prints the outputs line for integer n sa shown in the sample above .

the algorithm for determining the prime factorization of an integer n is follows ;
1.while n is not a prime number do :
1.1 let K be the smallest prime that properly divides n.
1.2 K is a prime factor of n .
1.3 let n be n/k.


this is my try ;

#include <iostream>
#include <cmath>
using namespace std;
 bool isprime (int n)
             {
                  if (n&n==0 && n%1==0)
                  return true
                
                  
                  }
 int main() {     
     int n=2 , k;
   while(n<=100){
   
               
            k= isprime ( n);
            n++;
             
             }

Edited 5 Years Ago by __avd: Added [code] tags.

Comments
Fucking noob
Thanks for such a creative title. Happy holidays.

Really? You don't have time to write a program that takes me 20 minutes to write? Open your book, read, and then code some more to solve the problem. I don't help people who are straight up lazy or who procrastinate to the very last minute. And I get tired of reading multiple posts per day like this.

Why is this crap not deleted? Anyone who so blatantly ignores the rules should not only have the thread deleted, but be banned for a long time. If I recall, after you register, you are sent to the "rules" thread (not 100% sure) where it specifically states that for you to receive homework help, you have to show effort. Where is the effort?

Why is this crap not deleted? Anyone who so blatantly ignores the rules should not only have the thread deleted, but be banned for a long time. If I recall, after you register, you are sent to the "rules" thread (not 100% sure) where it specifically states that for you to receive homework help, you have to show effort. Where is the effort?

Thank God I'm not the only one who thinks like this!

JSPMA1988,

I completely agree with everything you said. First, such a title is a serious misuse of this forum's database. It doesn't take a genius to see that all the people who ask things such as "How do you get ..." will receive better answers than those who demand "help yo plz!". Secondly, saying you need it done and don't have the time is just more ammunition for people like you and I. What exactly was the original poster doing when he should have done the homework?

have anyy of yyou considered that the original poster has OCD? Everyy time I tyype "yy" I have to tyype it twice. Everyytime. Mayybe the poster's got a "l" problem?

I'm not a board-certified psychiatrist, but I'm fairly sure that's not the case. I think he suffers from CDH, can't do homework.

Just as a PSA: The more your title cries out for attention, the less attention it will get. The more intelligently written your title is, the more help you will probably get.

@geojia I'm almost certain it's not OCD. There are different frequencies of 'l' in both words, even though the second word is just pure computer/text messaging slang.

@floatingDivs I have $100 on the assumption that he was playing video games.

Regarding bad titles: just report the first post of the thread and someone from the mod forums might fix that.

Plus, let's not go too off-topic here; how about wait for the OP to explain his/her situation (though I doubt it would happen).

Edited 5 Years Ago by ~s.o.s~: n/a

Trick is that don't try to get two things at the same time. Find the prime numbers between 1 - 100 then go to the algorithm that you give.

Calculate the primes.
You have the list of prime.
Go from 1 through 100
If your number is in the list of prime
Print prime
Else
Calculate the numbers prime factors by dividing it to the primes starting from 2
Hold the primes that successively divides the number
Print them

This article has been dead for over six months. Start a new discussion instead.