문제

내가 만들려고 하는 프로그램을 인쇄하는 방법에는 많은 부드러운 숫자 내에 있는 간격.는 코드 부분은 여기:

countsmooth(_, [], _, _, Count) :-
   Count is 0.
countsmooth(X, [H|T], Min, Max, Count) :-
   (  Y is X*H,
      Y =< Max 
   -> (  Y >= Min 
      -> NewX is X*H,
         countsmooth(X, T, Min, Max, NCount1),
         countsmooth(NewX, [H|T], Min, Max, NCount2),
         Count is (1+NCount1+NCount2)

      ;  NewX is X*H,
         countsmooth(X, T, Min, Max, NCount1),
         countsmooth(NewX, [H|T], Min, Max, NCount2),
         Count is (NCount1+NCount2)
      )
   ;  Count is 0
   ).

smooth(B, I, J, Smooths) :- 
   (  B =< 1 
   -> Smooths is 0
   ;  I =:= 1 
   -> primes(B, FilPrimes),
      countsmooth(1, Filprimes, I, J, Count),
      Smooths is (1+Count)
   ;  primes(B, FilPrimes),
      countsmooth(1, Filprimes, I, J, Count),
      Smooths is Count
   ).

도 조건자 primes 을 만드는 모든 주요한에서 숫자 2 하기 B.

는 경우,예를 들어, B = 11, 다음 FilPrimes = [2,3,5,7,11].

When I call countsmooth 에 SWI-프롤로그 같은 ?- countsmooth(1, [2,3,5,7,11,13,17,19,23], 1, 100000000, Count).내가 결과를 얻을.

하지만 내가 전화 smooth?- smooth(2,100,10000,Smooths). 나는 다음과 같은 오류가:

ERROR: is/2: Arguments are not sufficiently instantiated

올바른 솔루션이 없습니다

다른 팁

정말 죄송합니다.려고 노력했습니 모든 일을 찾아서 무엇이 잘못되어 있는지 그리고 마지막으로 나는 보았다는 것에 동일한 장소를 내가 쓴"FilPrimes"과 다른 장소에서"Filprimes".

나는 바보 같!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top