-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_fprime.c
41 lines (38 loc) · 1.24 KB
/
ft_fprime.c
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_fprime.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igarbuz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/18 23:12:17 by igarbuz #+# #+# */
/* Updated: 2018/11/18 23:16:44 by igarbuz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_fprime(unsigned long int i)
{
unsigned long int d;
d = 2;
if (!i)
ft_putchar('\n');
if (i == 1)
ft_putendl("1");
if (ft_isprime(i))
{
ft_putnbr(i);
ft_putchar('\n');
return ;
}
while (d * d <= i)
{
if ((i % d) == 0 && ft_isprime(d))
{
ft_putnbr(d);
ft_putchar('*');
ft_fprime(i / d);
return ;
}
d++;
}
}