diff options
author | Orangerot <purple@orangerot.dev> | 2024-05-17 15:10:54 +0200 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2024-05-17 15:10:54 +0200 |
commit | a1895fe157e06ee4d119576163ea76390b3d402c (patch) | |
tree | 7309a9ece74fb791cd3379b2b230d480e101d200 /2022/day11/test.c | |
parent | 0537a2bae5230485e7d0be9569617ae12bba223a (diff) |
2022 day11
Diffstat (limited to '2022/day11/test.c')
-rw-r--r-- | 2022/day11/test.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/2022/day11/test.c b/2022/day11/test.c new file mode 100644 index 0000000..fe9a076 --- /dev/null +++ b/2022/day11/test.c @@ -0,0 +1,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; +} |