Created
August 29, 2020 20:40
-
-
Save krestenlaust/a2a8e6bb5e9609812bb07a22f0defc4e to your computer and use it in GitHub Desktop.
Finder første tal af en primtal faktor opløsning, fx givet 60 = 2 x 2 x 3 x 5, giver den det første tal, altså 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Første tal til primtal faktorisering af Kresten den 29/08/20 | |
// 0th; 1st; 2nd; 3rd; 4th; 5th; 6th; 7th | |
// tæller; 0; dividend; 0; divisor; 0; 0; 0 | |
+ // tæller = 1 | |
>> // dividend | |
++++ +++ // 2nd = stdin | |
>>> // 5th | |
+ // = non zero | |
[ | |
// reset 5th position to 0th | |
[ | |
- | |
] | |
<[ // reset 4th position to 0th | |
- | |
] | |
<<<< // tæller | |
+ // plus lig med 1 | |
// move 0th to 4th and 8th | |
[ | |
>>>> + | |
>>>> + | |
<<<< <<<< - | |
] | |
>>>> >>>>[ // move 8th to 0th | |
<<<< <<<< + // 1th plus plus | |
>>>> >>>> - // 8th | |
] | |
// gammel kode her | |
// set 3th to 0 | |
<<<< <[ | |
- | |
] | |
<<< // 0th | |
// INPUT | |
// 1st; 2nd; 3rd; 4th; 5th; 6th; 7th | |
// 0; dividend; 0; divisor; 0; 0; 0 | |
// mod | |
>> // 2nd | |
[ | |
>+ // 3rd plus 1 | |
>- // 4th minus 1 | |
>+ // 5th plus 1 | |
< // 4th | |
[>] // goto next 0; 6? | |
>[ // 7? | |
<+ | |
>- | |
] | |
<< | |
[<] | |
>- | |
] | |
// 0th; 1st; 2nd; 3rd; 4th; 5th; 6th; 7th | |
// tæller; 0; ud:0; dividend; d minus n%d; n%d; 0; 0 | |
<< // 0th | |
// 2nd = 3rd; 3rd = 0 | |
>>>[ | |
<+ | |
>- | |
] | |
>> // 5th | |
] | |
<<<<<. // 0th = stdout | |
// old code | |
//Copy 3rd to 2nd; for at flytte input | |
// move 3rd to 2nd and 8th | |
[ | |
- | |
<+ // 2nd plus plus | |
>>>> >>+ // 8th plus plus | |
<<<< < // 3rd | |
] | |
>>>> >[ // move 8th to 3rd | |
- | |
<<<< <+ // 3rd plus plus | |
>>>> > // 8th | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment