Submission

Status:
PPPPPPPPPP

Score: 100

User: Nathlol2

Problemset: แยกตัวประกอบ

Language: c

Time: 0.124 second

Submitted On: 2024-09-25 23:22:20

#include <stdio.h>
#include <string.h>

void factorize(int n) {
    int j;
    j = 2;
    int power_count=0;

    do {
        if (n % j == 0){
            power_count++;
            n = n / j;
        }

        else {
            if (power_count>0) {
                printf("%d^%d ", j, power_count);
                power_count=0;
            }
            j++;
        }
    }

    while (n > 1);
    if (power_count>0) {
        printf("%d^%d ", j, power_count);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    factorize(n);
}