1. ## [Help] Mysterious Numbers

Hello!

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?

Code:
```#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;

return esMisterioso;
}

int main()
{
int a, b, num = 0;
cin >> a >> b;
for ( int i = a; i <= b; i++)
{
if ( esMisterioso(i) ) num++;
}
cout << num;
return 0;
}```

2. Maybe this? FAQ > Stop my Windows Console from disappearing everytime I run my program? - Cprogramming.com

You also may want to flush the output buffer and print a newline after your output.

Code:
`cout << num << endl;`

3. as a bit of fun i added some little changes, nothing to do with the useful advice given by rags_to_riches though.

Code:
```#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;
cout << n << " si hombre!\n";
}

return esMisterioso;
}

int main()
{
int a, b, num = 0;
cin >> a >> b;

cout << "\nprocesando...\n\n";
for ( int i = a; i <= b; i++)
{
if ( esMisterioso(i) ) num++;
}
cout << "\n";
cout << "hay "<< num << " numeros misteriosos entre " << a << " y " << b << " inclusivo.\n\n";
return 0;
}```

4. Your code is correct. You might just want to add "cin.ignore();" so you can empty the buffer (after cin >> a >>b) and "cin.get();" by the end so it won't shutdown instantly.