Display the factors

Description:

Write a program to display all factors of given number Test Case 1 Input (stdin) 60 Expected Output Factors of 60 are: 1 2 3 4 5 6 10 12 15 20 30 60 Test Case 2 Input (stdin) 90 Expected Output Factors of 90 are: 1 2 3 5 6 9 10 15 18 30 45 90

Program :

#include <iostream>

using namespace std;

int main()

{

int number, temp = 1;

    cin >> number;

    cout << "Factors of " << number << " are:" << endl;

    while (temp <= number)

    {

        if (not(number % temp))

            cout << temp << "\n";

 

        temp++;

    }

}