User Tools

Site Tools


qna:lab-session:code1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

qna:lab-session:code1 [2024/04/24 15:31] (current)
xallos created
Line 1: Line 1:
 +<code c>#include <stdio.h>
  
 +void printFactors(int n)
 +{
 +    for (
 +         int factor = 2;
 +         factor <= n/(double)factor;
 +         factor++
 +    ) {
 +        while (n % factor == 0) {
 +            n /= factor;
 +            printf("%d ", factor);
 +        }
 +    }
 +
 +    if (n > 1) {
 +        printf("%d ", n);
 +    }
 +    printf("\n");
 +    return;
 +}
 +
 +int main() {
 +   printFactors(60);
 +   return 0;
 +}
 +</code>
qna/lab-session/code1.txt ยท Last modified: 2024/04/24 15:31 by xallos