I am new here, and created an account to ask for some help. Long story short: haven't touched C++ since High School, and need some help with a problem. I stupidly offered a girl some help and am a little stuck in making this work.
A number is "mysterious" if it can be properly divided by the number of factors it has. For ex.: 9 has 3 factors, and is divisible by 3. 12 has 6 factors and is divisible by 6.
I want to input a range and have it output the number of mysterious numbers within it. As soon as I enter the second number, my program closes though. Am I anywhere near my goal?
#include <iostream>using namespace std;
bool esMisterioso(int n)
bool esMisterioso = false;
int c = 0;
for ( int i = 1; i <= n; i++)
if ( n % i == 0 ) c++;
if ( n % c == 0 ) esMisterioso = true;
int a, b, num = 0;
cin >> a >> b;
for ( int i = a; i <= b; i++)
if ( esMisterioso(i) ) num++;
cout << num;