print a list of integers from 1 to N that are both divisible by 2 and 3.and after producing the list, count the numbers of integers found.
arjen
0
Junior Poster in Training
Recommended Answers
Jump to PostYou have to try first. Forum rules =)
But to get you started, you'll want to use a for loop. Inside your for loop you will do some math to figure if your number is divisible by either 2 or 3, and then have a counter variable for each …
Jump to PostRemember you also need to loop the code, what your doing now is checking the number 1, once and then the program ends.
while(x <= n) { if(x % 2 == 0 && x % 3 == 0) { cout << x << endl; count++; } x++; …
All 10 Replies
LevyDee
2
Posting Whiz in Training
prvnkmr449
-8
Junior Poster
arjen
0
Junior Poster in Training
arjen
0
Junior Poster in Training
prvnkmr449
-8
Junior Poster
LevyDee
2
Posting Whiz in Training
prvnkmr449
-8
Junior Poster
arjen
0
Junior Poster in Training
prvnkmr449
-8
Junior Poster
LevyDee
2
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.