```javascript // program to find the HCF or GCD of two integers ``` ```javascript ``` ```javascript let hcf; ``` ```javascript // take input ``` ```javascript const number1 = prompt('Enter a first positive integer: '); ``` ```javascript const number2 = prompt('Enter a second positive integer: '); ``` ```javascript ``` ```javascript // looping from 1 to number1 and number2 ``` ```javascript for (let i = 1; i <= number1 && i <= number2; i++) { ``` ```javascript ``` ```javascript // check if is factor of both integers ``` ```javascript if( number1 % i == 0 && number2 % i == 0) { ``` ```javascript hcf = i; ``` ```javascript } ``` ```javascript } ``` ```javascript ``` ```javascript // display the hcf ``` ```javascript console.log(`HCF of ${number1} and ${number2} is ${hcf}.`); ``` [#code](https://www.waivio.com/object/code) [#js](https://www.waivio.com/object/js) [#learning](https://www.waivio.com/object/learning)
author | daine-cherry | ||||||
---|---|---|---|---|---|---|---|
permlink | 6gpbdx-javascript-program-to-find-hcf-or-gcd | ||||||
category | waivio | ||||||
json_metadata | {"community":"waivio","app":"waivio/1.0.0","format":"markdown","timeOfPostCreation":1657175643091,"host":"www.waivio.com","users":[],"links":["http://www.waivio.com/object/code","http://www.waivio.com/object/js","http://www.waivio.com/object/learning"],"image":[],"wobj":{"wobjects":[{"object_type":"hashtag","objectName":"code","author_permlink":"code","percent":34},{"object_type":"hashtag","objectName":"js","author_permlink":"js","percent":33},{"object_type":"hashtag","objectName":"learning","author_permlink":"learning","percent":33}]},"tags":["waivio","code","js","learning"]} | ||||||
created | 2022-07-07 06:34:15 | ||||||
last_update | 2022-07-07 06:34:15 | ||||||
depth | 0 | ||||||
children | 0 | ||||||
last_payout | 2022-07-14 06:34:15 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.010 HBD | ||||||
curator_payout_value | 0.009 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 964 | ||||||
author_reputation | -52,208,833,245 | ||||||
root_title | "JavaScript Program to Find HCF or GCD" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 114,639,610 | ||||||
net_rshares | 37,148,355,273 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
spaminator | 0 | -2,761,722,196 | -0.1% | ||
wiv01 | 0 | 38,998,761,380 | 100% | ||
waivio.welcome | 0 | 550,863,378 | 1.08% | ||
waivio.com | 0 | 360,452,711 | 1.08% |