Hi, can someone help me about this problem or suggest some pseudocode?
if i input this numbers
12 ,24, 100
output should be
YES, YES, YES
i'm confused in writing the solution in code.
Hi, can someone help me about this problem or suggest some pseudocode?
if i input this numbers
12 ,24, 100
output should be
YES, YES, YES
i'm confused in writing the solution in code.
Can you post the code you are having problems with?
pseudo code:
begin loop
read number
print "YES"
end loop
import java.util.Scanner;
public class Divisor {
public static void main (String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Number: ");
int n = in.nextInt();
int counter = 0;
for (int i = 1; i <=n; i++) {
if (n % i == 0) {
counter++;
}
System.out.println(counter);
}
}
}
what is in my mind is to get the divisors then add them up. Then insert an if statement. The problem is i don't know how to add them up. :)
how to add them up.
After the new number is obtained, add it to the variable that is to accumulate the total:
total = total + newNumber;
or shorthand way:
total += newNumber;
Can you post pseudo code for what you are trying to do? Make a list of the steps the code should take to do what you want done. Each step in the list should be as simple as possible.
hi again, how do i add the divisors?
i tried doing that it gave me answers, but wrong :) i hope you can still help me.
total += newNumber
Please post the code you are having problems with and ask your questions about it.
I don't know what you mean by: how do i add the divisors?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.