Multiple of 30 Plus 1 or 2

The program must accept an integer N as the input. The program must print YES if N is exactly one or two more than a multiple of 30 as the output. Else the program must print NO as the output.

Example Input/Output 1:
Input:
31

Output:
YES

Example Input/Output 2:
Input:
63

Output:
NO

#include<stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    if(N % 30 == 1 || N % 30 == 2)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}
import java.util.*;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N % 30 == 1 || N % 30 == 2) {
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
}
N = int(input())
if N%30 == 1 or N%30 == 2:
print('YES')
else:
print('NO')
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;
    if(N % 30 == 1 || N % 30 == 2)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}
Previous Article

Split String Values - Palindrome

Next Article

Alphanumeric Palindrome

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *