Explanation
Well, we know that one year is the sum of 365 days(non-leap year). So the basic formula to convert days into years is to divide the number of days by number(365).
Number of years = (Number of days ) / 365
Algorithm
- Define the number of days to convert into years.
- Apply in the formula.
- Print the number of years.
Complexity
O(1)
Input:
days= 799;
Output:
Number of years = days / 365;
= 799 / 365
= 2
Python
Output:
C
Output:
JAVA
Output:
C#
Output:
PHP
Output: