What's wrong?

Doesn't display m.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "stdafx.h"


#include <iostream>
#include <cstdint>
int main(){

	std::cout << "Enter a Number .";
	int n;
	std::cin >> n;
	int m;
	for (m = n-1; m < n && m>n-1000 ; m = m-1);
	if (n % m == 0){
		std::cout << m;
	}

}
Last edited on
closed account (E0p9LyTq)
Idiotal wrote:
Doesn't display m.


This is one reason why --> for (m = n-1; m < n && m>n-1000 ; m = m-1); (The semi-colon)

Another reason is -> if (n % m == 0) (will only output when entering even numbers)
Topic archived. No new replies allowed.