Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void faktoriziraj(int a)
- {
- if(a==1)
- cout<<1<<endl;
- else
- {
- for(int i=2;i<=a;++i)
- {
- if(a%i==0 && a!=i)
- {
- cout<<i<<"*";
- faktoriziraj(a/i);
- break;
- }
- else if(a==i)
- {
- cout<<i<<endl;
- }
- }
- }
- }
- int main()
- {
- int n;
- cin>>n;
- for(int i=1;i<=n;i++)
- {
- cout<<i<<" = ";
- faktoriziraj(i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement