Möbius function: Difference between revisions
Content deleted Content added
Edited code to meet task requirements. |
|||
Line 1,299:
<lang python>
# Python Program to evaluate
# M(N) = 0 if any prime factor
# of N is contained twice
# M(N) = (-1)^(no of distinct
# prime factors)
# Python Program to
# evaluate Mobius def
Line 1,353 ⟶ 1,359:
# Driver Code
print("Mobius numbers from 1..99:")
for i in range(1, 100):
print
# This code is contributed by
# Manish Shaw(manishshaw1)</lang>
{{out}}
<pre>Mobius
▲ 1 -1 -1 0 -1 1 -1 0 0 1 -1 0 -1 1 1 0 -1 0 -1 0
▲Mobius Functions M(N) at N = 25 is: 0
1 1 -1 0 0 1 0 0 -1 -1 -1 0 1 1 1 0 -1 1 1 0▼
-1 -1 -1 0 0 1 -1 0 0 0 1 0 -1 0 1 0 1 1 -1 0
-1 1 0 0 1 -1 -1 0 1 -1 -1 0 -1 1 0 0 1 -1 -1 0
0 1 -1 0 1 1 1 0 -1 0 1 0 1 1 1 0 -1 0 0</pre>
Method 2 (Efficient)
Line 1,429 ⟶ 1,436:
# Driver Code
print("Mobius numbers from 1..99:")
for i in range(1, 100):
print
# This code is contributed by
# Manish Shaw(manishshaw1)</lang>
{{out}}
<pre>Mobius
-1 1 -1 0 -1 1 -1 0 0 1 -1 0 -1 1 1 0 -1 0 -1 0
1 1 -1 0 0 1 0 0 -1 -1 -1 0 1 1 1 0 -1 1 1 0
-1 -1 -1 0 0 1 -1 0 0 0 1 0 -1 0 1 0 1 1 -1 0
-1 1 0 0 1 -1 -1 0 1 -1 -1 0 -1 1 0 0 1 -1 -1 0
0 1 -1 0 1 1 1 0 -1 0 1 0 1 1 1 0 -1 0 0</pre>
=={{header|Raku}}==
|