aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/ee1301/wk3/lab3/primeFactor.cpp
blob: 093a0be8529841a6b6b4dd837a70eb9be57f42a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <cmath>
using namespace std;

void factorFinder (unsigned long long n) {
  unsigned long long i=2;
  while (pow(i,2)<=n) {
    if (n%i==0) {
      cout << i << "*";
      n/=i;
    } else {
      i++;
    }
  }
  if (n>1) {
    cout << n << endl;
  }
}

int main () {
  unsigned long long n;
  cout << "Input a positive integer: ";
  cin >> n;
  cout << "Factors: ";
  factorFinder(n);
}