Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to use and in c++ 
Cpp :: MPI_File_seek 
Cpp :: permutation and combination program in c++ 
Cpp :: Check if two stacks are the same using C++ 
Cpp :: icon on win32 button 
Cpp :: kruskal algorithm in c++ 
Cpp :: gcd of two number in c++ stl 
Cpp :: sum of 2 arrays c++ 
Cpp :: c++ const shared_ptr 
Cpp :: c++ login 
Cpp :: print all chrchetrs of a string c++ 
Cpp :: lower bound c++ 
Cpp :: operator overload 
Cpp :: what does : mean in c++ 
Cpp :: conditions in c++ 
Cpp :: convert from hex to decimal c++ 
Cpp :: trig in c++ 
Cpp :: binary add using strings 
Cpp :: opengl text rendering with 3d rendering 
C :: C bold output 
C :: get file extension from base64 string 
C :: haskell print 
C :: remove on condtion in vec rust 
C :: how to open jupyter notebook in local disk D 
C :: postgres random select 
C :: pass the pointer to the function 
C :: how to sleep in c 
C :: write a binary file c 
C :: how to modulo in c without % 
C :: set value of boolean in c 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =