#include <iostream>
usingnamespace std;
main()
{
int a;
int n;
cin >> a;
if (a%2==0)
cout << "Broj "<<a<<" je paran";
for (n=0; n>=a; n++) {
if (a%n==0)
cout << n;
}
return 0;
}
I am total beginner, and I was kinda experimenting.
Just wanted to know how am I going to make a program that checks if number is odd or even. If it's even, a message pop ups [ Broj je paran = Number is even].
If it's odd, program prints his dealers (e.g. 35, his dealers are 1, 5, 7 and 35)
I tried something up, so pls check it and tell me where I'm wrong.
I'm guessing instead of this: for (n=0; n>=a; n++) {
you meant this: for (n=0; n<=a; n++) {
EDIT - also you only really need to check numbers which are equal to or less than half of a, as any number's largest possible whole number factor is itself divided by 2
Thank you very much it's working, but still some problems. When I remove if(a%n==0), then program works perfectly and prints all numbers from 0 to number a. Problem is if I leave if, and try to print dealers, program stops working.