SlideShare a Scribd company logo
Create a test case for Euler problem 3:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Solution
#include
#include
// function to print all prime factors for a given number.
int primFact(long int n,int* arr)
{
long int i;
int j=0;
// Print the number of 2s that divide n
while (n%2 == 0)
{
arr[j++] = 2;
n = n/2;
}
// n must be odd at this point. So we can skip one element (Note i = i +2)
for (i = 3; i <= sqrt(n); i = i+2)
{
// While i divides n, print i and divide n
while (n%i == 0)
{
arr[j++] = i;
n = n/i;
}
}
/*
handle prime numbers;
*/
if (n > 2){
arr[j++] = n;
}
return j;
}
/* main function to test the prime factors functions.*/
int main()
{
long int n = 600851475143;
int arr[100];
int len = primFact(n,&arr[0]);
int i;
int max = arr[0];
for(i=1;i

More Related Content

Similar to Create a test case for Euler problem 3The prime factors of 13195 .pdf

3 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart23 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart2SSE_AndyLi
 
Write C++ program that when given a value N(read from cin)- produces a.docx
Write C++ program that when given a value N(read from cin)- produces a.docxWrite C++ program that when given a value N(read from cin)- produces a.docx
Write C++ program that when given a value N(read from cin)- produces a.docxkarlynwih
 
operating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdfoperating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdfaquazac
 
#include iostream using namespace std; void InsertionSort(int .pdf
#include iostream using namespace std; void InsertionSort(int .pdf#include iostream using namespace std; void InsertionSort(int .pdf
#include iostream using namespace std; void InsertionSort(int .pdfbrijmote
 
Write a program that prompts the user to enter a positive integer and.pdf
Write a program that prompts the user to enter a positive integer and.pdfWrite a program that prompts the user to enter a positive integer and.pdf
Write a program that prompts the user to enter a positive integer and.pdffeetshoemart
 
fraction_math.c for Project 5 Program Design fraction.pdf
fraction_math.c for Project 5  Program Design  fraction.pdffraction_math.c for Project 5  Program Design  fraction.pdf
fraction_math.c for Project 5 Program Design fraction.pdfanjanadistribution
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CSAAKASH KUMAR
 
c++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfc++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfdhavalbl38
 
Project Euler in Python
Project Euler in PythonProject Euler in Python
Project Euler in PythonTetsuo Koyama
 
#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docxajoy21
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sortShanmuga Raju
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfMuhammadMaazShaik
 
Array Array Array Array Array Array Arra
Array Array Array Array Array Array ArraArray Array Array Array Array Array Arra
Array Array Array Array Array Array ArraFaysalAhamed32
 
5. R basics
5. R basics5. R basics
5. R basicsFAO
 

Similar to Create a test case for Euler problem 3The prime factors of 13195 .pdf (20)

3 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart23 chapter2 algorithm_analysispart2
3 chapter2 algorithm_analysispart2
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
Qno 1 (e)
 
DAA Lab Work.docx
DAA Lab Work.docxDAA Lab Work.docx
DAA Lab Work.docx
 
Write C++ program that when given a value N(read from cin)- produces a.docx
Write C++ program that when given a value N(read from cin)- produces a.docxWrite C++ program that when given a value N(read from cin)- produces a.docx
Write C++ program that when given a value N(read from cin)- produces a.docx
 
operating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdfoperating system Linux,ubuntu,Mac#include stdio.h #include .pdf
operating system Linux,ubuntu,Mac#include stdio.h #include .pdf
 
#include iostream using namespace std; void InsertionSort(int .pdf
#include iostream using namespace std; void InsertionSort(int .pdf#include iostream using namespace std; void InsertionSort(int .pdf
#include iostream using namespace std; void InsertionSort(int .pdf
 
Write a program that prompts the user to enter a positive integer and.pdf
Write a program that prompts the user to enter a positive integer and.pdfWrite a program that prompts the user to enter a positive integer and.pdf
Write a program that prompts the user to enter a positive integer and.pdf
 
Recursive squaring
Recursive squaringRecursive squaring
Recursive squaring
 
fraction_math.c for Project 5 Program Design fraction.pdf
fraction_math.c for Project 5  Program Design  fraction.pdffraction_math.c for Project 5  Program Design  fraction.pdf
fraction_math.c for Project 5 Program Design fraction.pdf
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
c++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfc++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdf
 
Project Euler in Python
Project Euler in PythonProject Euler in Python
Project Euler in Python
 
#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx
 
Functions
FunctionsFunctions
Functions
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sort
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
 
Array Array Array Array Array Array Arra
Array Array Array Array Array Array ArraArray Array Array Array Array Array Arra
Array Array Array Array Array Array Arra
 
5. R basics
5. R basics5. R basics
5. R basics
 
Function
FunctionFunction
Function
 

More from barristeressaseren71

Construct a program that sorts a list (numbers or strings) then sear.pdf
Construct a program that sorts a list (numbers or strings) then sear.pdfConstruct a program that sorts a list (numbers or strings) then sear.pdf
Construct a program that sorts a list (numbers or strings) then sear.pdfbarristeressaseren71
 
Circular Flow of Economic ActivityYour instructor will assign you .pdf
Circular Flow of Economic ActivityYour instructor will assign you .pdfCircular Flow of Economic ActivityYour instructor will assign you .pdf
Circular Flow of Economic ActivityYour instructor will assign you .pdfbarristeressaseren71
 
b. What construction activities would be regulated under the CWA Why.pdf
b. What construction activities would be regulated under the CWA Why.pdfb. What construction activities would be regulated under the CWA Why.pdf
b. What construction activities would be regulated under the CWA Why.pdfbarristeressaseren71
 
Why are cells growing in a colony on solid media likely to be in many.pdf
Why are cells growing in a colony on solid media likely to be in many.pdfWhy are cells growing in a colony on solid media likely to be in many.pdf
Why are cells growing in a colony on solid media likely to be in many.pdfbarristeressaseren71
 
Which of the following statements is (are) trueI Gross and net .pdf
Which of the following statements is (are) trueI  Gross and net .pdfWhich of the following statements is (are) trueI  Gross and net .pdf
Which of the following statements is (are) trueI Gross and net .pdfbarristeressaseren71
 
Where is [Cl] normally highest, inside or outside of a cell How do.pdf
Where is [Cl] normally highest, inside or outside of a cell How do.pdfWhere is [Cl] normally highest, inside or outside of a cell How do.pdf
Where is [Cl] normally highest, inside or outside of a cell How do.pdfbarristeressaseren71
 
What is the difference between the personal contact model of communi.pdf
What is the difference between the personal contact model of communi.pdfWhat is the difference between the personal contact model of communi.pdf
What is the difference between the personal contact model of communi.pdfbarristeressaseren71
 
Volcanic eruptions affect many populated areas. Which of the followi.pdf
Volcanic eruptions affect many populated areas. Which of the followi.pdfVolcanic eruptions affect many populated areas. Which of the followi.pdf
Volcanic eruptions affect many populated areas. Which of the followi.pdfbarristeressaseren71
 
The following information, based on the 123118 Annual Report to Sha.pdf
The following information, based on the 123118 Annual Report to Sha.pdfThe following information, based on the 123118 Annual Report to Sha.pdf
The following information, based on the 123118 Annual Report to Sha.pdfbarristeressaseren71
 
Question 2 Since Gullivers travels is growing rapidly there is a ne.pdf
Question 2 Since Gullivers travels is growing rapidly there is a ne.pdfQuestion 2 Since Gullivers travels is growing rapidly there is a ne.pdf
Question 2 Since Gullivers travels is growing rapidly there is a ne.pdfbarristeressaseren71
 
132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf
132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf
132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdfbarristeressaseren71
 
Please answer the following questions 1 through 30QUESTION 1The .pdf
Please answer the following questions 1 through 30QUESTION 1The .pdfPlease answer the following questions 1 through 30QUESTION 1The .pdf
Please answer the following questions 1 through 30QUESTION 1The .pdfbarristeressaseren71
 
Name and describe (in your own words) the four sources of variance w.pdf
Name and describe (in your own words) the four sources of variance w.pdfName and describe (in your own words) the four sources of variance w.pdf
Name and describe (in your own words) the four sources of variance w.pdfbarristeressaseren71
 
M2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdf
M2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdfM2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdf
M2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdfbarristeressaseren71
 
1. Input the data into Minitab system. 2. Summarizing Gender find.pdf
1. Input the data into Minitab system. 2. Summarizing Gender find.pdf1. Input the data into Minitab system. 2. Summarizing Gender find.pdf
1. Input the data into Minitab system. 2. Summarizing Gender find.pdfbarristeressaseren71
 
Label the following figure which shows the evolutionary relationship .pdf
Label the following figure which shows the evolutionary relationship .pdfLabel the following figure which shows the evolutionary relationship .pdf
Label the following figure which shows the evolutionary relationship .pdfbarristeressaseren71
 
Interestingly enough, the Fibonacci numbers appear in quite unexpecte.pdf
Interestingly enough, the Fibonacci numbers appear in quite unexpecte.pdfInterestingly enough, the Fibonacci numbers appear in quite unexpecte.pdf
Interestingly enough, the Fibonacci numbers appear in quite unexpecte.pdfbarristeressaseren71
 
In what order did life progress on EarthSmall protocells; archaea.pdf
In what order did life progress on EarthSmall protocells; archaea.pdfIn what order did life progress on EarthSmall protocells; archaea.pdf
In what order did life progress on EarthSmall protocells; archaea.pdfbarristeressaseren71
 
In regards to the findings of Darwin on the intellectual differences.pdf
In regards to the findings of Darwin on the intellectual differences.pdfIn regards to the findings of Darwin on the intellectual differences.pdf
In regards to the findings of Darwin on the intellectual differences.pdfbarristeressaseren71
 
I know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdf
I know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdfI know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdf
I know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdfbarristeressaseren71
 

More from barristeressaseren71 (20)

Construct a program that sorts a list (numbers or strings) then sear.pdf
Construct a program that sorts a list (numbers or strings) then sear.pdfConstruct a program that sorts a list (numbers or strings) then sear.pdf
Construct a program that sorts a list (numbers or strings) then sear.pdf
 
Circular Flow of Economic ActivityYour instructor will assign you .pdf
Circular Flow of Economic ActivityYour instructor will assign you .pdfCircular Flow of Economic ActivityYour instructor will assign you .pdf
Circular Flow of Economic ActivityYour instructor will assign you .pdf
 
b. What construction activities would be regulated under the CWA Why.pdf
b. What construction activities would be regulated under the CWA Why.pdfb. What construction activities would be regulated under the CWA Why.pdf
b. What construction activities would be regulated under the CWA Why.pdf
 
Why are cells growing in a colony on solid media likely to be in many.pdf
Why are cells growing in a colony on solid media likely to be in many.pdfWhy are cells growing in a colony on solid media likely to be in many.pdf
Why are cells growing in a colony on solid media likely to be in many.pdf
 
Which of the following statements is (are) trueI Gross and net .pdf
Which of the following statements is (are) trueI  Gross and net .pdfWhich of the following statements is (are) trueI  Gross and net .pdf
Which of the following statements is (are) trueI Gross and net .pdf
 
Where is [Cl] normally highest, inside or outside of a cell How do.pdf
Where is [Cl] normally highest, inside or outside of a cell How do.pdfWhere is [Cl] normally highest, inside or outside of a cell How do.pdf
Where is [Cl] normally highest, inside or outside of a cell How do.pdf
 
What is the difference between the personal contact model of communi.pdf
What is the difference between the personal contact model of communi.pdfWhat is the difference between the personal contact model of communi.pdf
What is the difference between the personal contact model of communi.pdf
 
Volcanic eruptions affect many populated areas. Which of the followi.pdf
Volcanic eruptions affect many populated areas. Which of the followi.pdfVolcanic eruptions affect many populated areas. Which of the followi.pdf
Volcanic eruptions affect many populated areas. Which of the followi.pdf
 
The following information, based on the 123118 Annual Report to Sha.pdf
The following information, based on the 123118 Annual Report to Sha.pdfThe following information, based on the 123118 Annual Report to Sha.pdf
The following information, based on the 123118 Annual Report to Sha.pdf
 
Question 2 Since Gullivers travels is growing rapidly there is a ne.pdf
Question 2 Since Gullivers travels is growing rapidly there is a ne.pdfQuestion 2 Since Gullivers travels is growing rapidly there is a ne.pdf
Question 2 Since Gullivers travels is growing rapidly there is a ne.pdf
 
132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf
132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf
132017 Genetics Problems 1. Round shape is dominant to wrinkl.pdf
 
Please answer the following questions 1 through 30QUESTION 1The .pdf
Please answer the following questions 1 through 30QUESTION 1The .pdfPlease answer the following questions 1 through 30QUESTION 1The .pdf
Please answer the following questions 1 through 30QUESTION 1The .pdf
 
Name and describe (in your own words) the four sources of variance w.pdf
Name and describe (in your own words) the four sources of variance w.pdfName and describe (in your own words) the four sources of variance w.pdf
Name and describe (in your own words) the four sources of variance w.pdf
 
M2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdf
M2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdfM2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdf
M2 Discussion Hyperthermophiles “Like It Hot”33 unread replies.44.pdf
 
1. Input the data into Minitab system. 2. Summarizing Gender find.pdf
1. Input the data into Minitab system. 2. Summarizing Gender find.pdf1. Input the data into Minitab system. 2. Summarizing Gender find.pdf
1. Input the data into Minitab system. 2. Summarizing Gender find.pdf
 
Label the following figure which shows the evolutionary relationship .pdf
Label the following figure which shows the evolutionary relationship .pdfLabel the following figure which shows the evolutionary relationship .pdf
Label the following figure which shows the evolutionary relationship .pdf
 
Interestingly enough, the Fibonacci numbers appear in quite unexpecte.pdf
Interestingly enough, the Fibonacci numbers appear in quite unexpecte.pdfInterestingly enough, the Fibonacci numbers appear in quite unexpecte.pdf
Interestingly enough, the Fibonacci numbers appear in quite unexpecte.pdf
 
In what order did life progress on EarthSmall protocells; archaea.pdf
In what order did life progress on EarthSmall protocells; archaea.pdfIn what order did life progress on EarthSmall protocells; archaea.pdf
In what order did life progress on EarthSmall protocells; archaea.pdf
 
In regards to the findings of Darwin on the intellectual differences.pdf
In regards to the findings of Darwin on the intellectual differences.pdfIn regards to the findings of Darwin on the intellectual differences.pdf
In regards to the findings of Darwin on the intellectual differences.pdf
 
I know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdf
I know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdfI know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdf
I know that flavin adenine dinucleotide (FAD) and nicotinamide adeni.pdf
 

Recently uploaded

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxRaedMohamed3
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...Nguyen Thanh Tu Collection
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 

Recently uploaded (20)

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 

Create a test case for Euler problem 3The prime factors of 13195 .pdf

  • 1. Create a test case for Euler problem 3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Solution #include #include // function to print all prime factors for a given number. int primFact(long int n,int* arr) { long int i; int j=0; // Print the number of 2s that divide n while (n%2 == 0) { arr[j++] = 2; n = n/2; } // n must be odd at this point. So we can skip one element (Note i = i +2) for (i = 3; i <= sqrt(n); i = i+2) { // While i divides n, print i and divide n while (n%i == 0) { arr[j++] = i; n = n/i; } } /* handle prime numbers; */ if (n > 2){ arr[j++] = n; }
  • 2. return j; } /* main function to test the prime factors functions.*/ int main() { long int n = 600851475143; int arr[100]; int len = primFact(n,&arr[0]); int i; int max = arr[0]; for(i=1;i