|
Post by ddfskip on Jan 8, 2023 12:17:39 GMT -5
Trying to get this to spit out all mod 7's=0 and mod 49's=1 for the following numbers 2556-2576
[start]
let count =2555
[compute]
For B = 1 to 21 let count = count + B
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next B
end
results are outside my parameters except for 2576
results when run S year---2576
S year---2583
S year---2646
S year---2660
J year---2745
S year---2765
What am I doing wrong
|
|
|
Post by mknarr on Jan 8, 2023 13:42:38 GMT -5
let count =2555
[compute]
For B = 1 to 21 'let count = count + B 'I'm not sure but do you want if you want to go from 2556 to 2577 then count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next B
end
|
|
|
Post by tsh73 on Jan 8, 2023 14:18:33 GMT -5
While you have answer what's wrong, I still could suggest easier code. Simple: if you have "from..to" numbers, use FOR! (of course, result stays the same)
For count = 2556 to 2576 If count mod 7=0 then print "S year";"---";count If count mod 49=1 then print "J year";"---";count next
|
|
|
Post by ddfskip on Jan 8, 2023 14:42:54 GMT -5
Thank you Mknarr. So I have a comment and question or 2.
I thought a single quote was just for putting down notes but when I remove the single quote the program doesnt work. Where can I get a better handle on the ins and outs of Basic? Its been many years since I took a course. Can you explain why my program didnt work?? My logic behind it was that it would start at 2556 check mod7 and mod49 statements then print if true and then move on to next B moving up 1 to 2557, etc until B=21 which is 2576 and then end. Where is my thinking wrong here? why do I need count = count+1 ?? why does the single quote have to be there?? thanks
|
|
|
Post by ddfskip on Jan 8, 2023 14:46:08 GMT -5
tsh73. My reason for doing it this way is it is only beginning of program and eventially want to increase 2555 by 1 and loop through entire program. Perhaps I should explain what I am doing. I have something to do for a while but will be back to explain what I need. thanks
|
|
|
Post by tsh73 on Jan 8, 2023 16:03:35 GMT -5
Single quote turns everything after it to a comment So BASIC ignores it If you remove single quote, this line will be executed by BASIC so putting a (') before a line is a handy way to turn line off while preserving for future use (or leave as information/example/variant of a program before current)
You need all numbers from 2556 to 2576 Now,
count = count+1 takes count, adds 1, puts it back to count This way you get all the numbers 2557, 2558, 2559...
Now for comparison with
let count =2555 For B = 1 to 21 let count = count + B Of the first pass, B=1 so count = count + B gives us 2556 On the second pass B=2 count = count + B gives us 2556+2, that is 2558 . and we are just skipped a number On the third pass B=3 count = count + B gives us 2558+3, that is 2561 . and we are just skipped 2 numbers and so on This way you are NOT getting EVERY number and your numbers get past 2576 pretty fast (actually at B=6 count gets to 2576 )
|
|
|
Post by ddfskip on Jan 8, 2023 16:09:17 GMT -5
Ok so here is the what I am trying to Solve. 2555, 2556, etc are (year of the world) dates. I have a 450 year period which is a floating period because of 2 unknowns that surround it. What I do know is the total of the 2 unknowns we will call E and S. I only want to get Sabbaths and Jubilees in certain years with gaps in-between the years in question. The first period is actually 8 years not 21.....as in the program I wrote above. After the 8 year period there is a period of 40 gap years that I dont need Sabbath and Jubilee info for because I am only counting certain period in the 450 years. After the 40 year gap, I will have another Period of 18 years that I need Sabbath and Jubilee info for.......then a 80 year gap . Then another 20 year period of Sabbath and Jubilee years. Then another gap....... and so on until I come to the end of the 450 year period in question. So I am starting at year 2555........and need to float the 450 year period each year forward for 34 years which is the total of E + S. I know I really only need 7 consecutive years for the Sabbath years since then it would repeat. But unfortunately, it gets complicated with also having to figure in Jubilees. That is why I am doing all 34 years because as I move through the years the number of Sabbaths and Jubilee obviously changes. Ultimately, I am looking for a combination count of 22 (Sabbath+Jubilees) in any of the 34 years. So once I go through all the periods in question of the 450 years starting with year 2556, then I need to increase that by 1 until 34 periods are complete and I get the total of Sabbaths and Jubilees in each year from 2556 to 2590. There is a total of 8 blocks of dates finding Sabbath and Jubilee years with 7 gap periods. So somehow I need to loop each year through the 8 periods in question. I hope this is understandable and any help would be appreciated. let me know if you have questions on this thanks ddf
|
|
|
Post by ddfskip on Jan 8, 2023 16:30:55 GMT -5
Thank you for the explanation tsh73 that makes sense to me. I guess, for some reason, that I thought it would come back to 2555 each time and just add one to it on each loop but the 2555 is outside the look duh!!! appreciate your time
|
|
|
Post by ddfskip on Jan 8, 2023 16:43:54 GMT -5
So it looks like, thanks to all your help, I have figured how to get through the 1st 8 periods. I am not sure though once I get through the first year of info to loop it into the next year to start process all over until the 34 years are complete. So any help with final loop would be appreciated.
|
|
|
Post by mknarr on Jan 8, 2023 17:12:48 GMT -5
I think Tsh gave you the answer
For count = 2556 to 2576 If count mod 7=0 then print "S year";"---";count If count mod 49=1 then print "J year";"---";count next
If you are saying you want to go from 2556 and 34 more years just change it to For count =2556 to 2590
I uses the ' to indicate remarking that line so it doesn't run.
|
|
|
Post by ddfskip on Jan 8, 2023 19:11:49 GMT -5
Thanks guys !!! you have been a big help...just one more hurdle..... here is the problem in looping through the years 2556 to 2590.
once I get to the end of I the last of 8 periods the count is at 3005 so it has to be reset start loop at next number 2557 but it wants to reset after each loop so how do I reset it once and loop through all 34 numbers??
[Count] 'want to loop from 2556-2590 count = 2555
[compute]
For B = 1 to 8
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next B
count = count+40
For C=1 to 18
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next C
count=count+80
For D=1 to 20
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next D
count=count+40
For E=1 to 7
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next E
count=count+40
For F=1 to 3
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next F
count=count+45
For G=1 to 18
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next G
count=count+31
For H=1 to 40
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next H
count=count+40
For I=1 to 20
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next I
print count 'count shows a total of 3005 at the end of the first pass so needs to be reset without being reset on each loop
end
|
|
|
Post by ddfskip on Jan 9, 2023 0:39:41 GMT -5
ok so why doesnt this one work. It makes logical sense to me so I can only think I am not doing a correct operation. it just spits out the 1st pass over and over but does not increase by a year until count is greater than 2590
[count]
count = 2555
[compute]
For B = 1 to 8
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next B
count = count+40
For C=1 to 18
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next C
count=count+80
For D=1 to 20
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next D
count=count+40
For E=1 to 7
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next E
count=count+40
For F=1 to 3
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next F
count=count+45
For G=1 to 18
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next G
count=count+31
For H=1 to 40
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next H
count=count+40
For I=1 to 20
count =count +1
If count mod 7=0 then print "S year";"---";count
If count mod 49=1 then print "J year";"---";count
next I
count=2555 'resetting the count
count=count+1
print count ' this line spits out 2556 as it should and then I expected since its less than 2590 that it would go to [compute] and in 2nd pass B increases it to 2557 and continue to increase until count was greater than 2590 then end.
if count >2590 then end
goto [compute]
end
|
|
|
Post by Rod on Jan 9, 2023 3:01:36 GMT -5
How will it ever get to the high number if you keep setting it to 2556 just before you check.? You have coded an endless loop.
|
|
|
Post by tsh73 on Jan 9, 2023 3:40:04 GMT -5
is
count mod 49=1 actually right condition? I tried googling it says "every 50th year" so likely
count mod 50=someNumber
|
|
|
Post by ddfskip on Jan 9, 2023 7:38:47 GMT -5
Right Rod........thought of that through the night. So what is one to do if count increases on each pass and has to be reset. This is a tricky one
|
|