summaryrefslogtreecommitdiff
path: root/2022/day11/test.c
blob: fe9a076baab97fe7d7f6b0272c5bd478396b81ef (plain)
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
#include <stdio.h>
int main()
{
    int n;
    int num = 1;
    printf("Enter the number you want: ");
    scanf("%d", &n);
    for(int i=2; i*i<=n; i++)
    {
        while(n%i==0)//find all the occurrences of a prime factor
        {
            printf("%d\n",i);
            if (num % i != 0)
                num *= i;
            n/=i;
        }
    }
    if(n!=1)//if the number was originally a prime
    {
        printf("%d",n);
        num *= n;
    }
    printf("new %d\n", num);
    return 0;
}