import math
i = 0
Ifa < int(fibo) < b-1 : #int(fibo) : p_n digits
k = int(math.sqrt(int(fibo))) # Prepare to divide by root
for i in range(2,k+1):
result = int(fibo)%i
fibo_ = fibo
If result == 0: # Remaining 0: Non-decimal
break
If result!=0: #Remaining !=0:Minority
print("Pivot prime:",fivo_)
else:
print ("No Pivot Minority")
After you get more than 2 to 17 digits and make a Fibonacci sequence, You want to write a program that finds and outputs all the decimal numbers in the Fibonacci number of the corresponding digits.
Run the program when the number of digits is two.
Pivot prime: 13
No Fibo Minority
No Fibo Minority
No Fibo Minority
Fibo prime number: 89
It comes out like this When the number of digits is 7
No pivot decimal
No Fibo Minority
No Fibo Minority
No Fibo Minority
No Fibo Minority
It comes out as. What is the way to keep the number of Fibos from floating when the number of digits is two?
python
I don't know exactly because I think a part of the code is missing.
If you look at the code you uploaded, there is only one part that you print out, but they said it will be taken five times.
If I were to point out the parts that I can see,
a < int(fibo) < b-1
This expression is familiar to people, but Python is not quite understandable.
In Python, True corresponds to 1 and False corresponds to 0.
Since the above inequality is the same as (a < int(fibo) < b-1
, if a < int(fibo)
is true, that expression will soon become True < b-1
, and if it is greater than the number of 1 < b-1
.
I think there must have been a problem in this area, too.
And I don't know exactly how you want the code to work with just the questions you posted.
The only way to make sure that there's no Fibo minority is... You can erase the printout.
But I don't think you want it to float in all situations, so please tell me in detail exactly what conditions and how you want it to work next time.
© 2024 OneMinuteCode. All rights reserved.