Log in

View Full Version : Loops and specific numbers


radclifa
Nov 21, 2009, 08:23 PM
I need to count up the numbers of numbers divisible by 3 in a program. I know how to figure out which numbers are divisible by 3, but not how to get the program to give me a number for the numbers that fit that distinction

ScottGem
Nov 21, 2009, 08:26 PM
In your loop add a counter that you increment esh time the divisible by 3 condition is met.

slapshot_oi
Nov 25, 2009, 11:09 AM
Use a for-loop and pass your increment variable to a GCD function.

Also, you should use the Euclidean GCD algorithm.