Horje
The program must enter a natural number n from the console and find the number previous to n that is not divisible by 2 , 3 and 5 . Code Example
The program must enter a natural number n from the console and find the number previous to n that is not divisible by 2 , 3 and 5 .
#include <bits/stdc++.h>
using namespace std;
//use c++ 17
int main(){
    int n;
    cin>>n;
    for(int i =n-1;;i--){
    	if(i%2!=0 && i%3!=0 && i%5!=0){
    		cout<<i;
    		break;
		}
	}
	return 0;
}




Cpp

Related
Anagram solution in c++ Code Example Anagram solution in c++ Code Example
online ide c++ Code Example online ide c++ Code Example
codeforces Pangram in c++ Code Example codeforces Pangram in c++ Code Example
Lambda capture as const cpp Code Example Lambda capture as const cpp Code Example
std::random_device Code Example std::random_device Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11