-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.html
83 lines (77 loc) · 2.06 KB
/
Code.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html>
<head>
<title>Code page</title>
<style>
h2,h3,h4,section {
padding:0px 15%;
}
code,pre {
margin-left: 15%;
}
p{
text-align: center;
}
*{
text-align: center;
font-size: 30px;
}
</style>
</head>
<body>
<header style="text-align: center">
<h1>Welcome to Coding Page..</h1>
</header>
<hr>
<h2>Counts the digits in a number..</h2>
<section>
<h3 style="text-align: center">Python code for given problem statement</h3>
<code>
<pre style="border: 2px solid; align-self: center;">
// Python program to count the digits in a number
def count_digits(n):
n = str(n)
return len(n)
# Driver code
n = 456533457776
print(count_digits(n))
</pre>
</code>
</section>
<section>
<h3>Sample Inputs and Outputs...</h3>
<samp>
<pre>
Input : 12345
Output: Total No Of Words: 5
</pre>
</samp>
<samp>
<pre>
Input : 5342
Output: Total No Of Words: 4
</pre>
</samp>
<samp>
<pre>
Input : 42345221
Output: Total No Of Words: 8
</pre>
</samp>
</section>
<section>
<h3>Variables use in a program : <var>n , cnt</var></h3>
</section>
<section>
<h3>Complexity</h3>
<p>The above program iterates <s>n</s></sup> <strong> log<sub>10</sub>(n)</strong> times</p>
<p>So time complexity is <strong>O(log<sub>10</sub>(n))</strong></p>
</section>
<hr>
<footer>
<p>For more information
<a href="https://www.geeksforgeeks.org/program-count-digits-integer-3-different-methods/" target="_blank">Click here</a></p>
<p>Or visit <a href="https://www.geeksforgeeks.org/" target="_blank">GeeksForGeeks</a></p>
</footer>
</body>
</html>