Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- std:: vector<int> prosti_faktori(int n)
- {
- std:: vector<int>v;
- v.push_back(1);
- while(n!=1)
- {
- for(int i=2; i<=n; i++)
- {
- if(n%i==0)
- {
- v.push_back(i);
- n=n/i;
- break;
- }
- else continue;
- }
- }
- return v;
- }
- int main()
- {
- int n;
- std:: cout << "Unesite broj: ";
- std:: cin >> n;
- std::vector<int> v(prosti_faktori(n));
- std::cout << "Prosti faktori su: ";
- for(int x : v)
- std::cout << x << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement