Member Avatar for Ajantis

Hello :)

Suppose I input an int value with Scanner sc = new Scanner( and I want to count how many divisors that value has, how would I proceed in "recognizing" a divisor? if ((input/2)%10 == 0)? I'd prefer doing this recursively somehow. Can someone help? :)

Best Wishes!

a is a divisor of b iff (b%a == 0)
I have no idea how (or why) you would do this recursively - you just need a loop to try all values of a from 1 to sqrt(b)

Member Avatar for Ajantis

Ok, just needed what you said JamesCherrill. :) Thanks for the tips. I solved it now!

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.