SlideShare a Scribd company logo
1 of 2
Download to read offline
Comments added...
// method to check divisble by particular number....
public boolean isDivisibleBy(Node firstNode, int divisor){
// current node and previous node declaring for iterating purpose
Node curr = firstNode;
Node prev = null;
// boolean value holds divisble or not
boolean isDivible = true;
while(curr != null) // iterating until list ends reach
{
if(curr.data % divisor != 0){ // if not divisble then exit and change flag to false
isDivible = false;
break;
}
// iterate to next node
prev = curr;
curr = curr.next;
}
// return result
return isDivible;
}
Solution
Comments added...
// method to check divisble by particular number....
public boolean isDivisibleBy(Node firstNode, int divisor){
// current node and previous node declaring for iterating purpose
Node curr = firstNode;
Node prev = null;
// boolean value holds divisble or not
boolean isDivible = true;
while(curr != null) // iterating until list ends reach
{
if(curr.data % divisor != 0){ // if not divisble then exit and change flag to false
isDivible = false;
break;
}
// iterate to next node
prev = curr;
curr = curr.next;
}
// return result
return isDivible;
}

More Related Content

More from anushkaent7

The phylogenetic origin of the flu virus that caused the 2009 pandem.pdf
The phylogenetic origin of the flu virus that caused the 2009 pandem.pdfThe phylogenetic origin of the flu virus that caused the 2009 pandem.pdf
The phylogenetic origin of the flu virus that caused the 2009 pandem.pdf
anushkaent7
 
The Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdfThe Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdf
anushkaent7
 
Plasma membrane of human is made of phospholipids; these are fluids .pdf
Plasma membrane of human is made of phospholipids; these are fluids .pdfPlasma membrane of human is made of phospholipids; these are fluids .pdf
Plasma membrane of human is made of phospholipids; these are fluids .pdf
anushkaent7
 
One of the functions of skin is to regulate the temperature. The ski.pdf
One of the functions of skin is to regulate the temperature. The ski.pdfOne of the functions of skin is to regulate the temperature. The ski.pdf
One of the functions of skin is to regulate the temperature. The ski.pdf
anushkaent7
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
anushkaent7
 
Connects corresponding regions of left and right cerebral hemisphere.pdf
Connects corresponding regions of left and right cerebral hemisphere.pdfConnects corresponding regions of left and right cerebral hemisphere.pdf
Connects corresponding regions of left and right cerebral hemisphere.pdf
anushkaent7
 
As per the above scenario, please find the short report below.The .pdf
As per the above scenario, please find the short report below.The .pdfAs per the above scenario, please find the short report below.The .pdf
As per the above scenario, please find the short report below.The .pdf
anushkaent7
 
AnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdf
AnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdfAnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdf
AnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdf
anushkaent7
 

More from anushkaent7 (20)

The phylogenetic origin of the flu virus that caused the 2009 pandem.pdf
The phylogenetic origin of the flu virus that caused the 2009 pandem.pdfThe phylogenetic origin of the flu virus that caused the 2009 pandem.pdf
The phylogenetic origin of the flu virus that caused the 2009 pandem.pdf
 
The Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdfThe Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdf
 
Question 1Answer b. The returned value, return address, paramete.pdf
Question 1Answer b. The returned value, return address, paramete.pdfQuestion 1Answer b. The returned value, return address, paramete.pdf
Question 1Answer b. The returned value, return address, paramete.pdf
 
Plasma membrane of human is made of phospholipids; these are fluids .pdf
Plasma membrane of human is made of phospholipids; these are fluids .pdfPlasma membrane of human is made of phospholipids; these are fluids .pdf
Plasma membrane of human is made of phospholipids; these are fluids .pdf
 
Please post the exact proplem in comments.SolutionPlease post .pdf
Please post the exact proplem in comments.SolutionPlease post .pdfPlease post the exact proplem in comments.SolutionPlease post .pdf
Please post the exact proplem in comments.SolutionPlease post .pdf
 
P( both correct) = P( first correct)P( second correct) = 1212 = .pdf
P( both correct) = P( first correct)P( second correct) = 1212 = .pdfP( both correct) = P( first correct)P( second correct) = 1212 = .pdf
P( both correct) = P( first correct)P( second correct) = 1212 = .pdf
 
One of the functions of skin is to regulate the temperature. The ski.pdf
One of the functions of skin is to regulate the temperature. The ski.pdfOne of the functions of skin is to regulate the temperature. The ski.pdf
One of the functions of skin is to regulate the temperature. The ski.pdf
 
None of the options.SolutionNone of the options..pdf
None of the options.SolutionNone of the options..pdfNone of the options.SolutionNone of the options..pdf
None of the options.SolutionNone of the options..pdf
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
 
It is a test for iron(III) ion present in the solution , so it is a .pdf
It is a test for iron(III) ion present in the solution , so it is a .pdfIt is a test for iron(III) ion present in the solution , so it is a .pdf
It is a test for iron(III) ion present in the solution , so it is a .pdf
 
C. 12Solution C. 12.pdf
  C.  12Solution  C.  12.pdf  C.  12Solution  C.  12.pdf
C. 12Solution C. 12.pdf
 
I think that y=21SolutionI think that y=21.pdf
I think that y=21SolutionI think that y=21.pdfI think that y=21SolutionI think that y=21.pdf
I think that y=21SolutionI think that y=21.pdf
 
Connects corresponding regions of left and right cerebral hemisphere.pdf
Connects corresponding regions of left and right cerebral hemisphere.pdfConnects corresponding regions of left and right cerebral hemisphere.pdf
Connects corresponding regions of left and right cerebral hemisphere.pdf
 
c) Li is oxidized F is reduced as li goes to +1 oxidation state an.pdf
c) Li is oxidized F is reduced as li goes to +1 oxidation state an.pdfc) Li is oxidized F is reduced as li goes to +1 oxidation state an.pdf
c) Li is oxidized F is reduced as li goes to +1 oxidation state an.pdf
 
Balance sheet of Doctors PartnershipNotesPartners capital con.pdf
Balance sheet of Doctors PartnershipNotesPartners capital con.pdfBalance sheet of Doctors PartnershipNotesPartners capital con.pdf
Balance sheet of Doctors PartnershipNotesPartners capital con.pdf
 
As per the above scenario, please find the short report below.The .pdf
As per the above scenario, please find the short report below.The .pdfAs per the above scenario, please find the short report below.The .pdf
As per the above scenario, please find the short report below.The .pdf
 
Answer B.nitrile hydrolysis reactionNitrilase which catalyzes the.pdf
Answer B.nitrile hydrolysis reactionNitrilase which catalyzes the.pdfAnswer B.nitrile hydrolysis reactionNitrilase which catalyzes the.pdf
Answer B.nitrile hydrolysis reactionNitrilase which catalyzes the.pdf
 
AnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdf
AnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdfAnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdf
AnswerQuestion no 37 and 38 are not clear. 37) what molecules abs.pdf
 
Allopatric speciation occurs due to change of environment, like jump.pdf
Allopatric speciation occurs due to change of environment, like jump.pdfAllopatric speciation occurs due to change of environment, like jump.pdf
Allopatric speciation occurs due to change of environment, like jump.pdf
 
An adaptation of the epithelial cells of the proximal convoluted tub.pdf
An adaptation of the epithelial cells of the proximal convoluted tub.pdfAn adaptation of the epithelial cells of the proximal convoluted tub.pdf
An adaptation of the epithelial cells of the proximal convoluted tub.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Recently uploaded (20)

The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 

Comments added... method to check divisble by particular number..pdf

  • 1. Comments added... // method to check divisble by particular number.... public boolean isDivisibleBy(Node firstNode, int divisor){ // current node and previous node declaring for iterating purpose Node curr = firstNode; Node prev = null; // boolean value holds divisble or not boolean isDivible = true; while(curr != null) // iterating until list ends reach { if(curr.data % divisor != 0){ // if not divisble then exit and change flag to false isDivible = false; break; } // iterate to next node prev = curr; curr = curr.next; } // return result return isDivible; } Solution Comments added... // method to check divisble by particular number.... public boolean isDivisibleBy(Node firstNode, int divisor){ // current node and previous node declaring for iterating purpose Node curr = firstNode; Node prev = null; // boolean value holds divisble or not boolean isDivible = true; while(curr != null) // iterating until list ends reach { if(curr.data % divisor != 0){ // if not divisble then exit and change flag to false
  • 2. isDivible = false; break; } // iterate to next node prev = curr; curr = curr.next; } // return result return isDivible; }