小编Sub*_*ash的帖子

C中的主要因素

我遇到了这个有效的程序来打印给定数字的所有主要因素:

# include <stdio.h>
# include <math.h>

// A function to print all prime factors of a given number n
void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n%2 == 0)
    {
        printf("%d ", 2);
        n = n/2;
    }

    // n must be odd at this point.  So we can skip 
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // While i …
Run Code Online (Sandbox Code Playgroud)

c primes algebra sqrt

1
推荐指数
1
解决办法
125
查看次数

标签 统计

algebra ×1

c ×1

primes ×1

sqrt ×1