Find the Smaller Angle.
PrepBuddy has an analog clock which consists of two hands one for hour and another for minute. She wants to calculate the shorter angle formed between hour and minute hand at any given time. The input contains two number h
and
m
, which represents the current time as hour and minutes.
Note:
Complete the Minimal_Angle
function. No need to take any input.
h
and
m
, which represents the current time as hour and minutes.
Minimal_Angle
function. No need to take any input.
var Minimal_Angle = (h, m) => {
let hrAngle = (((h * 360) / 12) + ((m *360) / (12 * 60)));
let minAngle = ((m * 360) / 60);
let angle = Math.abs(hrAngle - minAngle);
if(angle >= 180){
angle = 360 - angle;
}
return angle;
};
Check whether the year is Leap year or not.
Write a program which takes an year N
as input from the user and find out whether the given year is a Leap Year or not
Note: Complete the Check_Leap
function. No need to take any input.
N
as input from the user and find out whether the given year is a Leap Year or notCheck_Leap
function. No need to take any input.var Check_Leap = (year) => {
if((year % 4 === 0) && (year % 100 !== 0) || (year % 400 === 0)){
return "Leap Year";
}
else return "Non Leap Year";
};
Perfect Number Check.
Have you heard of Perfect numbers? If not let me tell you what is it, Perfect Numbers are integers that are equal to the sum of all its divisors except that number itself.
Now, You are given an integer N
, write a program to check whether the given number is a Perfect Number or not.
Note: Complete the Perfect_Check
function. No need to take any input.
Now, You are given an integer
N
, write a program to check whether the given number is a Perfect Number or not.
Perfect_Check
function. No need to take any input.var Perfect_Check = (N) => {
let sum = 1;
for(let i = 1; i < N; i++){
sum += i;
}
if(sum === N){
return "YES"
}
else return "NO";
};
Reverse a Number.
Write a program which takes a numebr N
as input from the user and You need to reverse the number.
Note: Complete the Reverse_Number
function. No need to take any input.
N
as input from the user and You need to reverse the number.Reverse_Number
function. No need to take any input.var Reverse_Number = (N) => {
let reverse = 0;
while(N > 0){
reverse = reverse * 10 + N % 10;
N = Math.floor(N / 10);
}
return reverse;
};
Substring Check.
You are given two strings S1
and S2
, you need to check whether the string S1 is a substring of string S2 or not.
Note: Complete the Substring_Check
function. No need to take any input.
S1
and S2
, you need to check whether the string S1 is a substring of string S2 or not.Substring_Check
function. No need to take any input.var Substring_Check = (S1, S2) => {
const arr = S1.split(" ");
for(let i=0;i < arr.length;i++){
if(arr[i] === S2){
return "YES";
}
}
return "NO";
};