FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
C/project_euler/Problem 03/sol2.c at master · SelfCodeLearning/C · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SelfCodeLearning
/
C
Public
forked from
TheAlgorithms/C
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
C
/
project_euler
/
Problem 03
/
sol2.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (22 loc) · 413 Bytes
Breadcrumbs
C
/
project_euler
/
Problem 03
/
sol2.c
Copy path
File metadata and controls
23 lines (22 loc) · 413 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
Problem:
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
*/
#include
<stdio.h>
int
main
() {
int
n
=
0
;
scanf
(
"%d"
,
&
n
);
int
prime
=
1
;
int
i
=
2
;
while
(
i
*
i
<=
n
) {
while
(
n
%
i
==
0
) {
prime
=
i
;
n
/=
i
;
}
i
+=
1
;
}
if
(
n
>
1
)
prime
=
n
;
printf
(
"%d\n"
,
prime
);
}
Back
|
FazBrowse Home
|
New Git URL