Time when minute hand and hour hand coincide
Given time in hours, find the time in minutes at which the minute hand and hour hand coincide in the next one hour.
Examples:
Input : 3
Output : (180/11) minutes
Input :7
Output : (420/11) minutes
Approach :
1. Take two variables for hour “h1 and h2” and then find the angle “theta” [theta = (30 * h1)] and then divide it by “11” to find the time in minute(m). We are dividing with 11, because the hands of a clock coincide 11s time in 12 hours and 22 times in 24 hours :
Formula : This can be calculated using the formula for time h1 to h2 means [11m / 2 – 30 (h1)]
this implies [ m = ((30 * h1) * 2) / 11 ] ]
[ m = (theta * 2) / 11 ]
where [theta = (30 * h1) ]
where A and B are hours i.e if given hour is (2, 3) then A = 2 and B = 3 .
C++
#include <bits/stdc++.h>
using namespace std;
void find_time( int h1)
{
int theta = 30 * h1;
cout << "(" << (theta * 2) << "/"
<< "11"
<< ")"
<< " minutes" ;
}
int main() {
int h1 = 3;
find_time(h1);
return 0;
}
|
JAVA
import java.io.*;
class GFG
{
static void find_time( int h1)
{
int theta = 30 * h1;
System.out.println( "(" + theta *
2 + "/" +
" 11 ) minutes" );
}
public static void main (String[] args)
{
int h1 = 3 ;
find_time(h1);
}
}
|
Python3
def find_time(h1):
theta = 30 * h1
print ( "(" , end = "")
print ((theta * 2 ), "/ 11) minutes" )
h1 = 3
find_time(h1)
|
C#
using System;
class GFG
{
static void find_time( int h1)
{
int theta = 30 * h1;
Console.WriteLine( "(" + theta * 2 +
"/" + " 11 )minutes" );
}
public static void Main()
{
int h1 = 3;
find_time(h1);
}
}
|
PHP
<?php
function find_time( $h1 )
{
$theta = 30 * $h1 ;
echo ( "(" . ( $theta * 2) .
"/" . "11" . ")" .
" minutes" );
}
$h1 = 3;
find_time( $h1 );
?>
|
Javascript
<script>
function find_time(h1)
{
theta = 30 * h1;
document.write( "(" + (theta * 2) + "/"
+ "11"
+ ")"
+ " minutes" );
}
h1 = 3;
find_time(h1);
</script>
|
Output :
(180/11) minutes
Time Complexity: O(1)
Auxiliary Space: O(1)
Last Updated :
02 Aug, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...