Jump to content
43oh

MochaSatin

Members
  • Content Count

    2
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    MochaSatin got a reaction from jsolarski in Generating random numbers.   
    Here is a small code snippet for the linear congruential generator. Adjust for you needs:
     
    #include
     
    int main()
    {
    int M = 256;
    int a = 65;
    int c = 27;
    int X = 1;
    int i;
     
    for(i=0; i<256; i++)
    {
    X=(a * X + c) % M;
    printf("%d ", X);
    }
     
    return 0;
    }
     
    Output:
     
    92 119 82 237 72 99 62 217 52 79 42 197 32 59 22 177 12 39 2 157 248 19 238 137
    228 255 218 117 208 235 198 97 188 215 178 77 168 195 158 57 148 175 138 37 128
    155 118 17 108 135 98 253 88 115 78 233 68 95 58 213 48 75 38 193 28 55 18 173 8
    35 254 153 244 15 234 133 224 251 214 113 204 231 194 93 184 211 174 73 164 191
    154 53 144 171 134 33 124 151 114 13 104 131 94 249 84 111 74 229 64 91 54 209
    44 71 34 189 24 51 14 169 4 31 250 149 240 11 230 129 220 247 210 109 200 227 19
    0 89 180 207 170 69 160 187 150 49 140 167 130 29 120 147 110 9 100 127 90 245 8
    0 107 70 225 60 87 50 205 40 67 30 185 20 47 10 165 0 27 246 145 236 7 226 125 2
    16 243 206 105 196 223 186 85 176 203 166 65 156 183 146 45 136 163 126 25 116 1
    43 106 5 96 123 86 241 76 103 66 221 56 83 46 201 36 63 26 181 16 43 6 161 252 2
    3 242 141 232 3 222 121 212 239 202 101 192 219 182 81 172 199 162 61 152 179 14
    2 41 132 159 122 21 112 139 102 1
  2. Like
    MochaSatin got a reaction from RobG in Generating random numbers.   
    Here is a small code snippet for the linear congruential generator. Adjust for you needs:
     
    #include
     
    int main()
    {
    int M = 256;
    int a = 65;
    int c = 27;
    int X = 1;
    int i;
     
    for(i=0; i<256; i++)
    {
    X=(a * X + c) % M;
    printf("%d ", X);
    }
     
    return 0;
    }
     
    Output:
     
    92 119 82 237 72 99 62 217 52 79 42 197 32 59 22 177 12 39 2 157 248 19 238 137
    228 255 218 117 208 235 198 97 188 215 178 77 168 195 158 57 148 175 138 37 128
    155 118 17 108 135 98 253 88 115 78 233 68 95 58 213 48 75 38 193 28 55 18 173 8
    35 254 153 244 15 234 133 224 251 214 113 204 231 194 93 184 211 174 73 164 191
    154 53 144 171 134 33 124 151 114 13 104 131 94 249 84 111 74 229 64 91 54 209
    44 71 34 189 24 51 14 169 4 31 250 149 240 11 230 129 220 247 210 109 200 227 19
    0 89 180 207 170 69 160 187 150 49 140 167 130 29 120 147 110 9 100 127 90 245 8
    0 107 70 225 60 87 50 205 40 67 30 185 20 47 10 165 0 27 246 145 236 7 226 125 2
    16 243 206 105 196 223 186 85 176 203 166 65 156 183 146 45 136 163 126 25 116 1
    43 106 5 96 123 86 241 76 103 66 221 56 83 46 201 36 63 26 181 16 43 6 161 252 2
    3 242 141 232 3 222 121 212 239 202 101 192 219 182 81 172 199 162 61 152 179 14
    2 41 132 159 122 21 112 139 102 1
  3. Like
    MochaSatin got a reaction from bluehash in Generating random numbers.   
    Here is a small code snippet for the linear congruential generator. Adjust for you needs:
     
    #include
     
    int main()
    {
    int M = 256;
    int a = 65;
    int c = 27;
    int X = 1;
    int i;
     
    for(i=0; i<256; i++)
    {
    X=(a * X + c) % M;
    printf("%d ", X);
    }
     
    return 0;
    }
     
    Output:
     
    92 119 82 237 72 99 62 217 52 79 42 197 32 59 22 177 12 39 2 157 248 19 238 137
    228 255 218 117 208 235 198 97 188 215 178 77 168 195 158 57 148 175 138 37 128
    155 118 17 108 135 98 253 88 115 78 233 68 95 58 213 48 75 38 193 28 55 18 173 8
    35 254 153 244 15 234 133 224 251 214 113 204 231 194 93 184 211 174 73 164 191
    154 53 144 171 134 33 124 151 114 13 104 131 94 249 84 111 74 229 64 91 54 209
    44 71 34 189 24 51 14 169 4 31 250 149 240 11 230 129 220 247 210 109 200 227 19
    0 89 180 207 170 69 160 187 150 49 140 167 130 29 120 147 110 9 100 127 90 245 8
    0 107 70 225 60 87 50 205 40 67 30 185 20 47 10 165 0 27 246 145 236 7 226 125 2
    16 243 206 105 196 223 186 85 176 203 166 65 156 183 146 45 136 163 126 25 116 1
    43 106 5 96 123 86 241 76 103 66 221 56 83 46 201 36 63 26 181 16 43 6 161 252 2
    3 242 141 232 3 222 121 212 239 202 101 192 219 182 81 172 199 162 61 152 179 14
    2 41 132 159 122 21 112 139 102 1
×
×
  • Create New...